react-native-video-trim 8.1.5 → 8.1.6
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.
|
@@ -68,7 +68,6 @@ open class BaseVideoTrimModule internal constructor(
|
|
|
68
68
|
private val sendEvent: (eventName: String, params: WritableMap?) -> Unit
|
|
69
69
|
) : VideoTrimListener, LifecycleEventListener {
|
|
70
70
|
|
|
71
|
-
private var isInit: Boolean = false
|
|
72
71
|
private var trimmerView: VideoTrimmerView? = null
|
|
73
72
|
private var alertDialog: AlertDialog? = null
|
|
74
73
|
private var mProgressDialog: AlertDialog? = null
|
|
@@ -84,6 +83,10 @@ open class BaseVideoTrimModule internal constructor(
|
|
|
84
83
|
private var pendingSaveToDocumentsFile: File? = null
|
|
85
84
|
|
|
86
85
|
init {
|
|
86
|
+
// Initialize BaseUtils eagerly so DeviceUtil / VideoTrimmerUtil static
|
|
87
|
+
// fields resolve correctly even when a headless API (compress, toGif,
|
|
88
|
+
// merge, …) is called before showEditor has ever been opened.
|
|
89
|
+
BaseUtils.init(reactApplicationContext)
|
|
87
90
|
reactApplicationContext.addLifecycleEventListener(this)
|
|
88
91
|
|
|
89
92
|
val mActivityEventListener = object : BaseActivityEventListener() {
|
|
@@ -190,11 +193,6 @@ open class BaseVideoTrimModule internal constructor(
|
|
|
190
193
|
onError("Activity is not available", ErrorCode.UNKNOWN)
|
|
191
194
|
return
|
|
192
195
|
}
|
|
193
|
-
if (!isInit) {
|
|
194
|
-
init()
|
|
195
|
-
isInit = true
|
|
196
|
-
}
|
|
197
|
-
|
|
198
196
|
// here is NOT main thread, we need to create VideoTrimmerView on UI thread, so that later we can update it using same thread
|
|
199
197
|
UiThreadUtil.runOnUiThread {
|
|
200
198
|
trimmerView = VideoTrimmerView(reactApplicationContext, editorConfig, null)
|
|
@@ -290,12 +288,6 @@ open class BaseVideoTrimModule internal constructor(
|
|
|
290
288
|
}
|
|
291
289
|
}
|
|
292
290
|
|
|
293
|
-
private fun init() {
|
|
294
|
-
isInit = true
|
|
295
|
-
// we have to init this before create videoTrimmerView
|
|
296
|
-
BaseUtils.init(reactApplicationContext)
|
|
297
|
-
}
|
|
298
|
-
|
|
299
291
|
override fun onHostResume() {
|
|
300
292
|
Log.d(TAG, "onHostResume: ")
|
|
301
293
|
}
|
|
@@ -741,7 +733,9 @@ open class BaseVideoTrimModule internal constructor(
|
|
|
741
733
|
speed != 1.0 -> cmds.addAll(listOf("-af", VideoTrimmerUtil.buildAtempoChain(speed)))
|
|
742
734
|
else -> cmds.addAll(listOf("-c:a", "copy"))
|
|
743
735
|
}
|
|
744
|
-
|
|
736
|
+
// Same high-tbr fix as compress: prevents duplicate DTS on sources like Pixel 7
|
|
737
|
+
// recordings (45k tbr) when re-encoding with h264_mediacodec.
|
|
738
|
+
cmds.addAll(listOf("-fps_mode", "vfr", "-metadata", "creation_time=$formattedDateTime", resolvedOutputFile))
|
|
745
739
|
cmds.toTypedArray()
|
|
746
740
|
}
|
|
747
741
|
|
|
@@ -907,7 +901,11 @@ open class BaseVideoTrimModule internal constructor(
|
|
|
907
901
|
} else {
|
|
908
902
|
cmds.addAll(listOf("-c:a", "aac"))
|
|
909
903
|
}
|
|
910
|
-
|
|
904
|
+
// -fps_mode vfr prevents frame duplication / non-monotonic DTS errors that
|
|
905
|
+
// occur when the source has an unusually high time-base (e.g. Pixel 7 recordings
|
|
906
|
+
// with 45k tbr). Without this, h264_mediacodec tries to encode at the tbr rate,
|
|
907
|
+
// producing hundreds of duplicate frames and then a fatal muxer DTS collision.
|
|
908
|
+
cmds.addAll(listOf("-fps_mode", "vfr", "-y", outputFile))
|
|
911
909
|
cmds.toTypedArray()
|
|
912
910
|
}
|
|
913
911
|
|