react-native-video-trim 8.1.2 → 8.1.3

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.
@@ -690,7 +690,9 @@ open class BaseVideoTrimModule internal constructor(
690
690
 
691
691
  if (!needsReEncode) {
692
692
  // Stream copy: no encoder is opened so the fallback chain doesn't apply.
693
+ // -y overwrites any pre-existing output file without prompting.
693
694
  val cmds = mutableListOf(
695
+ "-y",
694
696
  "-ss", "${startTime}ms",
695
697
  "-to", "${endTime}ms",
696
698
  "-i", url,
@@ -721,7 +723,11 @@ open class BaseVideoTrimModule internal constructor(
721
723
  } catch (_: Exception) {}
722
724
 
723
725
  val buildCommand: (List<String>) -> Array<String> = { encoderArgs ->
726
+ // -y overwrites the output file without prompting, so the encoder fallback
727
+ // chain's software retry can reuse the same output path left behind by the
728
+ // failed hardware attempt instead of aborting on FFmpeg's overwrite prompt.
724
729
  val cmds = mutableListOf(
730
+ "-y",
725
731
  "-ss", "${startTime}ms",
726
732
  "-to", "${endTime}ms",
727
733
  "-i", url,
@@ -297,7 +297,8 @@ object VideoTrimmerUtil {
297
297
  if (!needsReEncode) {
298
298
  // Stream copy: no re-encoding, extremely fast but only cuts at keyframes.
299
299
  // No encoder is opened so the fallback chain doesn't apply — single attempt.
300
- val cmds = mutableListOf("-ss", "${startMs}ms", "-to", "${endMs}ms", "-i", inputFile)
300
+ // -y overwrites any pre-existing output file without prompting.
301
+ val cmds = mutableListOf("-y", "-ss", "${startMs}ms", "-to", "${endMs}ms", "-i", inputFile)
301
302
  if (removeAudio) {
302
303
  cmds.addAll(listOf("-c:v", "copy", "-an"))
303
304
  } else {
@@ -354,7 +355,11 @@ object VideoTrimmerUtil {
354
355
  // Note: Android FFmpegKit auto-rotates by default, so no -noautorotate is needed.
355
356
  // The transpose filters above only handle user-initiated rotation, not source metadata.
356
357
  val buildCommand: (List<String>) -> Array<String> = { encoderArgs ->
357
- val cmds = mutableListOf("-ss", "${startMs}ms", "-to", "${endMs}ms", "-i", inputFile)
358
+ // -y overwrites the output file without prompting. This is critical for the
359
+ // encoder fallback chain: the first (hardware) attempt opens/creates the output
360
+ // file before MediaCodec fails, so the software retry reuses the same path and
361
+ // would otherwise hit FFmpeg's interactive "Overwrite? [y/N]" prompt and abort.
362
+ val cmds = mutableListOf("-y", "-ss", "${startMs}ms", "-to", "${endMs}ms", "-i", inputFile)
358
363
  // When enablePreciseTrimming is the only reason for re-encode (no transforms),
359
364
  // videoFilters is empty — skip -vf entirely to avoid FFmpeg error on empty filter.
360
365
  if (filterString.isNotEmpty()) {
@@ -359,7 +359,11 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
359
359
  root.present(progressAlert, animated: true, completion: nil)
360
360
  }
361
361
 
362
+ // -y overwrites any pre-existing output file without prompting, so FFmpeg never
363
+ // blocks on an interactive "Overwrite? [y/N]" prompt (hardening; also keeps the
364
+ // command symmetric with Android, where -y is required by the encoder fallback chain).
362
365
  var cmds = [
366
+ "-y",
363
367
  "-ss",
364
368
  "\(startTime * 1000)ms",
365
369
  "-to",
@@ -648,7 +652,9 @@ public class VideoTrim: RCTEventEmitter, AssetLoaderDelegate, UIDocumentPickerDe
648
652
 
649
653
  let startTime = config["startTime"] as? Double ?? 0
650
654
  let endTime = config["endTime"] as? Double ?? 0
655
+ // -y overwrites any pre-existing output file without prompting (hardening).
651
656
  var cmds = [
657
+ "-y",
652
658
  "-ss",
653
659
  "\(startTime)ms",
654
660
  "-to",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-video-trim",
3
- "version": "8.1.2",
3
+ "version": "8.1.3",
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",