maitrungduc1410 / react-native-video-trim

Video trimmer for React Native App
MIT License
37 stars 14 forks source link

After cutting the video, the video cannot be saved #16

Closed yanghun0070 closed 5 months ago

yanghun0070 commented 5 months ago

After cutting the video, the video cannot be saved. The video cannot be played. An error appears saying

maitrungduc1410 commented 5 months ago

Hi what error message is it?

Which platform are you facing the issue? Ios or android

Are you using real device?

yanghun0070 commented 5 months ago

Occurs on android. No error message occurs. However, if it appears as a blank screen as shown in the screenshot, a message will appear saying that there is no video when you click.

1 2

yanghun0070 commented 5 months ago

I don’t think it can be saved properly after trimming.

maitrungduc1410 commented 5 months ago

Is it possible for you to share me the sample video?

Also share me option you pass to showEditor

yanghun0070 commented 5 months ago

The options are simple. It seems like an Android path recognition issue.

                  showEditor(galleries[galleryIndex].uri, {
                    maxDuration: 30,
                  })
                    .then((res) => console.log("res:" + res))
                    .catch((e) => console.log("e:" + e));
                }}

https://github.com/maitrungduc1410/react-native-video-trim/assets/22450400/87f1ce20-0a61-40b8-a55a-a10deb9aad98

yanghun0070 commented 5 months ago

There seems to be a file format error in iOS. onError {"message": "File is invalid", "name": "onError"}

uri: "ph://D9958F6F-AC62-431F-A08A-6A991579F189"

maitrungduc1410 commented 5 months ago

Okay, I'll check and get back to you soon

maitrungduc1410 commented 5 months ago

I tried with your video on my Device, it's working fine.

As shown in my video, I did 2 samples, with same option for showEditor as yours.

in the end of the video you can see that both samples are generated fine

https://github.com/maitrungduc1410/react-native-video-trim/assets/16630193/4aac3ef4-b48f-4f60-9169-803fcb79f895

yanghun0070 commented 5 months ago

I'm getting the same error

https://github.com/maitrungduc1410/react-native-video-trim/assets/22450400/d099fc88-5dc3-4e0b-a91f-d69d407734b4

maitrungduc1410 commented 5 months ago

Hi @yanghun0070 Can you try kill the photo app and reopen to see?

maitrungduc1410 commented 5 months ago

If it persists, can you run your project with your device connected using Android Studio?

Then at the time you're about to click Save, pay attention to Log Cat to see is there any suspicious when saving ?

yanghun0070 commented 5 months ago

After adding the code below, Android works normally.

  public static void saveVideoToGallery(ReactApplicationContext context, String videoFilePath) throws IOException {
    Log.w(TAG, "videoFilePath:" + videoFilePath);
    File videoFile = new File(videoFilePath);
    // Create the file if it doesn't exist
    if (!videoFile.exists()) {
      boolean isFileCreated = videoFile.createNewFile();
      Log.w(TAG, "File Created: " + isFileCreated);
    }

@maitrungduc1410 The error below occurs in iOS. Do you know what causes it?

There seems to be a file format error in iOS. onError {"message": "File is invalid", "name": "onError"}

uri: "ph://D9958F6F-AC62-431F-A08A-6A991579F189"

maitrungduc1410 commented 5 months ago

On ios you need to run on real device, don't you?

maitrungduc1410 commented 5 months ago

Btw where did you add the code for saveVideoToGallery?

yanghun0070 commented 5 months ago

@maitrungduc1410 I think it was an image library issue. I solved it by changing the ph:// path to the file path.

The added code is as follows.

    File videoFile = new File(videoFilePath);

    // Create the file if it doesn't exist
    if (!videoFile.exists()) {
      boolean isFileCreated = videoFile.createNewFile();
      Log.w(TAG, "File Created: " + isFileCreated);
    }
maitrungduc1410 commented 5 months ago

fixed in 1.0.8