react-native-video-trim 2.2.1 → 2.2.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.
package/README.md
CHANGED
|
@@ -385,8 +385,8 @@ If there's error while loading media, there'll be a prompt
|
|
|
385
385
|
|
|
386
386
|
Related props: `alertOnFailToLoad, alertOnFailTitle, alertOnFailMessage, alertOnFailCloseText`
|
|
387
387
|
|
|
388
|
-
# FFMPEG
|
|
389
|
-
This library uses FFMPEG-Kit Android under the hood, by default FFMPEG
|
|
388
|
+
# Customize FFMPEG version
|
|
389
|
+
This library uses FFMPEG-Kit Android under the hood, by default FFMPEG `min` is used, which gives smallest bundle size. To customize the package version please see below
|
|
390
390
|
|
|
391
391
|
## Android
|
|
392
392
|
If you ever need to use other version of FFMPEG-Kit for Android, you can do the following, in your `android/build.gradle` > `buildscript` > `ext`:
|
|
@@ -415,6 +415,55 @@ FFMPEGKIT_PACKAGE_VERSION=5.1 npx pod-install ios
|
|
|
415
415
|
FFMPEGKIT_PACKAGE=full FFMPEGKIT_PACKAGE_VERSION=5.1 npx pod-install ios
|
|
416
416
|
```
|
|
417
417
|
|
|
418
|
+
## Packages
|
|
419
|
+
|
|
420
|
+
<table>
|
|
421
|
+
<thead>
|
|
422
|
+
<tr>
|
|
423
|
+
<th align="center"></th>
|
|
424
|
+
<th align="center"><sup>min</sup></th>
|
|
425
|
+
<th align="center"><sup>min-gpl</sup></th>
|
|
426
|
+
<th align="center"><sup>https</sup></th>
|
|
427
|
+
<th align="center"><sup>https-gpl</sup></th>
|
|
428
|
+
<th align="center"><sup>audio</sup></th>
|
|
429
|
+
<th align="center"><sup>video</sup></th>
|
|
430
|
+
<th align="center"><sup>full</sup></th>
|
|
431
|
+
<th align="center"><sup>full-gpl</sup></th>
|
|
432
|
+
</tr>
|
|
433
|
+
</thead>
|
|
434
|
+
<tbody>
|
|
435
|
+
<tr>
|
|
436
|
+
<td align="center"><sup>external libraries</sup></td>
|
|
437
|
+
<td align="center">-</td>
|
|
438
|
+
<td align="center"><sup>vid.stab</sup><br><sup>x264</sup><br><sup>x265</sup><br><sup>xvidcore</sup></td>
|
|
439
|
+
<td align="center"><sup>gmp</sup><br><sup>gnutls</sup></td>
|
|
440
|
+
<td align="center"><sup>gmp</sup><br><sup>gnutls</sup><br><sup>vid.stab</sup><br><sup>x264</sup><br><sup>x265</sup><br><sup>xvidcore</sup></td>
|
|
441
|
+
<td align="center"><sup>lame</sup><br><sup>libilbc</sup><br><sup>libvorbis</sup><br><sup>opencore-amr</sup><br><sup>opus</sup><br><sup>shine</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>twolame</sup><br><sup>vo-amrwbenc</sup></td>
|
|
442
|
+
<td align="center"><sup>dav1d</sup><br><sup>fontconfig</sup><br><sup>freetype</sup><br><sup>fribidi</sup><br><sup>kvazaar</sup><br><sup>libass</sup><br><sup>libiconv</sup><br><sup>libtheora</sup><br><sup>libvpx</sup><br><sup>libwebp</sup><br><sup>snappy</sup><br><sup>zimg</sup></td>
|
|
443
|
+
<td align="center"><sup>dav1d</sup><br><sup>fontconfig</sup><br><sup>freetype</sup><br><sup>fribidi</sup><br><sup>gmp</sup><br><sup>gnutls</sup><br><sup>kvazaar</sup><br><sup>lame</sup><br><sup>libass</sup><br><sup>libiconv</sup><br><sup>libilbc</sup><br><sup>libtheora</sup><br><sup>libvorbis</sup><br><sup>libvpx</sup><br><sup>libwebp</sup><br><sup>libxml2</sup><br><sup>opencore-amr</sup><br><sup>opus</sup><br><sup>shine</sup><br><sup>snappy</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>twolame</sup><br><sup>vo-amrwbenc</sup><br><sup>zimg</sup></td>
|
|
444
|
+
<td align="center"><sup>dav1d</sup><br><sup>fontconfig</sup><br><sup>freetype</sup><br><sup>fribidi</sup><br><sup>gmp</sup><br><sup>gnutls</sup><br><sup>kvazaar</sup><br><sup>lame</sup><br><sup>libass</sup><br><sup>libiconv</sup><br><sup>libilbc</sup><br><sup>libtheora</sup><br><sup>libvorbis</sup><br><sup>libvpx</sup><br><sup>libwebp</sup><br><sup>libxml2</sup><br><sup>opencore-amr</sup><br><sup>opus</sup><br><sup>shine</sup><br><sup>snappy</sup><br><sup>soxr</sup><br><sup>speex</sup><br><sup>twolame</sup><br><sup>vid.stab</sup><br><sup>vo-amrwbenc</sup><br><sup>x264</sup><br><sup>x265</sup><br><sup>xvidcore</sup><br><sup>zimg</sup></td>
|
|
445
|
+
</tr>
|
|
446
|
+
<tr>
|
|
447
|
+
<td align="center"><sup>android system libraries</sup></td>
|
|
448
|
+
<td align="center" colspan=8><sup>zlib</sup><br><sup>MediaCodec</sup></td>
|
|
449
|
+
</tr>
|
|
450
|
+
<tr>
|
|
451
|
+
<td align="center"><sup>ios system libraries</sup></td>
|
|
452
|
+
<td align="center" colspan=8><sup>bzip2</sup><br><sup>AudioToolbox</sup><br><sup>AVFoundation</sup><br><sup>iconv</sup><br><sup>VideoToolbox</sup><br><sup>zlib</sup></td>
|
|
453
|
+
</tr>
|
|
454
|
+
<tr>
|
|
455
|
+
<tr>
|
|
456
|
+
<td align="center"><sup>macos system libraries</sup></td>
|
|
457
|
+
<td align="center" colspan=8><sup>bzip2</sup><br><sup>AudioToolbox</sup><br><sup>AVFoundation</sup><br><sup>Core Image</sup><br><sup>iconv</sup><br><sup>OpenCL</sup><br><sup>OpenGL</sup><br><sup>VideoToolbox</sup><br><sup>zlib</sup></td>
|
|
458
|
+
</tr>
|
|
459
|
+
<tr>
|
|
460
|
+
<td align="center"><sup>tvos system libraries</sup></td>
|
|
461
|
+
<td align="center" colspan=8><sup>bzip2</sup><br><sup>AudioToolbox</sup><br><sup>iconv</sup><br><sup>VideoToolbox</sup><br><sup>zlib</sup></td>
|
|
462
|
+
</tr>
|
|
463
|
+
</tbody>
|
|
464
|
+
</table>
|
|
465
|
+
|
|
466
|
+
|
|
418
467
|
# Android: update SDK version
|
|
419
468
|
You can override sdk version to use any version in your `android/build.gradle` > `buildscript` > `ext`
|
|
420
469
|
```gradle
|
|
@@ -427,6 +476,13 @@ buildscript {
|
|
|
427
476
|
}
|
|
428
477
|
```
|
|
429
478
|
|
|
479
|
+
# Naming conflict with `ffmpeg-kit-react-native`
|
|
480
|
+
This issue is due to this package and `ffmpeg-kit-react-native` share FFMPEG Kit under the hood. To fix it we need to synchronize the FFMPEG Kit version of the 2 packages.
|
|
481
|
+
|
|
482
|
+
First find out exactly FFMPEG Kit version that `ffmpeg-kit-react-native` is using. By default (if you don't change), the ffmpeg package is `https` ([check here](https://github.com/arthenica/ffmpeg-kit/blob/main/react-native/ffmpeg-kit-react-native.podspec#L19)) and version is `version` in [package.json](https://github.com/arthenica/ffmpeg-kit/blob/main/react-native/package.json#L3)
|
|
483
|
+
|
|
484
|
+
When you know the package name + version, simply follow the section [Customize FFMPEG version](#customize-ffmpeg-version) in this doc
|
|
485
|
+
|
|
430
486
|
# Thanks
|
|
431
487
|
- Android part is created by modified + fix bugs from: https://github.com/iknow4/Android-Video-Trimmer
|
|
432
488
|
- iOS UI is created from: https://github.com/AndreasVerhoeven/VideoTrimmerControl
|
|
@@ -260,14 +260,6 @@ public class VideoTrimModule extends ReactContextBaseJavaModule implements Video
|
|
|
260
260
|
sendEvent(getReactApplicationContext(), "onLoad", map);
|
|
261
261
|
}
|
|
262
262
|
|
|
263
|
-
@Override
|
|
264
|
-
public void onStartTrim() {
|
|
265
|
-
sendEvent(getReactApplicationContext(), "onStartTrimming", null);
|
|
266
|
-
runOnUiThread(() -> {
|
|
267
|
-
buildDialog();
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
|
|
271
263
|
@Override
|
|
272
264
|
public void onTrimmingProgress(int percentage) {
|
|
273
265
|
// prevent onTrimmingProgress is called after onFinishTrim (some rare cases)
|
|
@@ -361,7 +353,7 @@ public class VideoTrimModule extends ReactContextBaseJavaModule implements Video
|
|
|
361
353
|
@Override
|
|
362
354
|
public void onSave() {
|
|
363
355
|
if (!enableSaveDialog) {
|
|
364
|
-
|
|
356
|
+
startTrim();
|
|
365
357
|
return;
|
|
366
358
|
}
|
|
367
359
|
|
|
@@ -371,7 +363,7 @@ public class VideoTrimModule extends ReactContextBaseJavaModule implements Video
|
|
|
371
363
|
builder.setCancelable(false);
|
|
372
364
|
builder.setPositiveButton(saveDialogConfirmText, (dialog, which) -> {
|
|
373
365
|
dialog.cancel();
|
|
374
|
-
|
|
366
|
+
startTrim();
|
|
375
367
|
});
|
|
376
368
|
builder.setNegativeButton(saveDialogCancelText, (dialog, which) -> {
|
|
377
369
|
dialog.cancel();
|
|
@@ -390,32 +382,7 @@ public class VideoTrimModule extends ReactContextBaseJavaModule implements Video
|
|
|
390
382
|
sendEvent(getReactApplicationContext(), "onStatistics", statistics);
|
|
391
383
|
}
|
|
392
384
|
|
|
393
|
-
private void
|
|
394
|
-
// handle the case when the cancel dialog is still showing but the trimming is finished
|
|
395
|
-
if (cancelTrimmingConfirmDialog != null) {
|
|
396
|
-
if (cancelTrimmingConfirmDialog.isShowing()) {
|
|
397
|
-
cancelTrimmingConfirmDialog.dismiss();
|
|
398
|
-
}
|
|
399
|
-
cancelTrimmingConfirmDialog = null;
|
|
400
|
-
}
|
|
401
|
-
|
|
402
|
-
if (mProgressDialog != null) {
|
|
403
|
-
if (mProgressDialog.isShowing()) mProgressDialog.dismiss();
|
|
404
|
-
mProgressBar = null;
|
|
405
|
-
mProgressDialog = null;
|
|
406
|
-
}
|
|
407
|
-
|
|
408
|
-
if (shouldCloseEditor) {
|
|
409
|
-
if (alertDialog != null) {
|
|
410
|
-
if (alertDialog.isShowing()) {
|
|
411
|
-
alertDialog.dismiss();
|
|
412
|
-
}
|
|
413
|
-
alertDialog = null;
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
private void buildDialog() {
|
|
385
|
+
private void startTrim() {
|
|
419
386
|
Activity activity = getReactApplicationContext().getCurrentActivity();
|
|
420
387
|
// Create the parent layout for the dialog
|
|
421
388
|
LinearLayout layout = new LinearLayout(activity);
|
|
@@ -482,6 +449,7 @@ public class VideoTrimModule extends ReactContextBaseJavaModule implements Video
|
|
|
482
449
|
cancelTrimmingConfirmDialog.show();
|
|
483
450
|
} else {
|
|
484
451
|
trimmerView.onCancelTrimClicked();
|
|
452
|
+
|
|
485
453
|
if (mProgressDialog != null && mProgressDialog.isShowing()) {
|
|
486
454
|
mProgressDialog.dismiss();
|
|
487
455
|
}
|
|
@@ -497,9 +465,40 @@ public class VideoTrimModule extends ReactContextBaseJavaModule implements Video
|
|
|
497
465
|
|
|
498
466
|
// Show the dialog
|
|
499
467
|
mProgressDialog = builder.create();
|
|
468
|
+
|
|
469
|
+
mProgressDialog.setOnShowListener(dialog -> {
|
|
470
|
+
sendEvent(getReactApplicationContext(), "onStartTrimming", null);
|
|
471
|
+
trimmerView.onSaveClicked();
|
|
472
|
+
});
|
|
473
|
+
|
|
500
474
|
mProgressDialog.show();
|
|
501
475
|
}
|
|
502
476
|
|
|
477
|
+
private void hideDialog(boolean shouldCloseEditor) {
|
|
478
|
+
// handle the case when the cancel dialog is still showing but the trimming is finished
|
|
479
|
+
if (cancelTrimmingConfirmDialog != null) {
|
|
480
|
+
if (cancelTrimmingConfirmDialog.isShowing()) {
|
|
481
|
+
cancelTrimmingConfirmDialog.dismiss();
|
|
482
|
+
}
|
|
483
|
+
cancelTrimmingConfirmDialog = null;
|
|
484
|
+
}
|
|
485
|
+
|
|
486
|
+
if (mProgressDialog != null) {
|
|
487
|
+
if (mProgressDialog.isShowing()) mProgressDialog.dismiss();
|
|
488
|
+
mProgressBar = null;
|
|
489
|
+
mProgressDialog = null;
|
|
490
|
+
}
|
|
491
|
+
|
|
492
|
+
if (shouldCloseEditor) {
|
|
493
|
+
if (alertDialog != null) {
|
|
494
|
+
if (alertDialog.isShowing()) {
|
|
495
|
+
alertDialog.dismiss();
|
|
496
|
+
}
|
|
497
|
+
alertDialog = null;
|
|
498
|
+
}
|
|
499
|
+
}
|
|
500
|
+
}
|
|
501
|
+
|
|
503
502
|
@ReactMethod
|
|
504
503
|
public void addListener(String eventName) {
|
|
505
504
|
// This method is required by React
|
|
@@ -5,7 +5,6 @@ import com.videotrim.enums.ErrorCode;
|
|
|
5
5
|
|
|
6
6
|
public interface VideoTrimListener {
|
|
7
7
|
void onLoad(int duration);
|
|
8
|
-
void onStartTrim();
|
|
9
8
|
void onTrimmingProgress(int percentage);
|
|
10
9
|
void onFinishTrim(String url, long startMs, long endMs, int videoDuration);
|
|
11
10
|
void onCancelTrim();
|