react-native-video-trim 8.1.3 → 8.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/ios/VideoTrim.swift +10 -19
  2. package/package.json +1 -1
@@ -382,22 +382,13 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
382
382
  let needsReEncode = hasUserTransform || cropNorm != nil || enablePreciseTrimming || needsSpeed
383
383
 
384
384
  if needsReEncode, let vc = vc {
385
- // -noautorotate disables FFmpeg's automatic rotation, so we must manually
386
- // compensate for the source video's rotation metadata via transpose filters.
387
- if let asset = vc.asset,
388
- let videoTrack = asset.tracks(withMediaType: .video).first {
389
- let t = videoTrack.preferredTransform
390
- let sourceAngle = atan2(t.b, t.a)
391
- if abs(sourceAngle - .pi / 2) < 0.1 {
392
- videoFilters.append("transpose=1")
393
- } else if abs(sourceAngle + .pi / 2) < 0.1 {
394
- videoFilters.append("transpose=2")
395
- } else if abs(abs(sourceAngle) - .pi) < 0.1 {
396
- videoFilters.append("transpose=1")
397
- videoFilters.append("transpose=1")
398
- }
399
- }
400
-
385
+ // Let FFmpeg autorotate the source (note: NO -noautorotate below). Autorotate bakes
386
+ // the source rotation matrix into upright, display-orientation pixels AND strips the
387
+ // matrix from the output. The previous approach (-noautorotate + a manual source-
388
+ // compensation transpose) baked the pixels but left the source rotation matrix on the
389
+ // output, so on ffmpeg-kit 6 every rotation-tagged portrait clip came out
390
+ // double-rotated (sideways). User rotate/flip and crop below operate on the already-
391
+ // upright autorotated frame, so their math is unchanged.
401
392
  switch vc.rotationCount {
402
393
  case 1: videoFilters.append("transpose=2")
403
394
  case 2:
@@ -464,9 +455,9 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
464
455
  }
465
456
  }
466
457
 
467
- // -noautorotate: we handle rotation via explicit transpose filters above,
468
- // so FFmpeg must not auto-rotate or the output will be double-rotated.
469
- cmds.append("-noautorotate")
458
+ // NOTE: intentionally NO -noautorotate. FFmpeg autorotates the input so the source
459
+ // rotation is baked into the pixels and the output carries no stale rotation matrix
460
+ // (otherwise rotation-tagged portrait clips are double-rotated -> sideways on ffmpeg-kit 6).
470
461
  cmds.append(contentsOf: ["-i", inputFile.path])
471
462
  // When enablePreciseTrimming is the only reason for re-encode (no transforms),
472
463
  // videoFilters is empty — skip -vf entirely to avoid FFmpeg error on empty filter.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "8.1.3",
3
+ "version": "8.1.4",
4
4
  "description": "Video trimmer for your React Native app",
5
5
  "main": "./lib/module/index.js",
6
6
  "types": "./lib/typescript/src/index.d.ts",