Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yanghun0070 opened this issue Nov 30, 2023 · 16 comments
Closed

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

yanghun0070 opened this issue Nov 30, 2023 · 16 comments

Comments

@yanghun0070
Copy link

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

@maitrungduc1410
Copy link
Owner

Hi what error message is it?

Which platform are you facing the issue? Ios or android

Are you using real device?

@yanghun0070
Copy link
Author

yanghun0070 commented Nov 30, 2023

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
Copy link
Author

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

@maitrungduc1410
Copy link
Owner

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

Also share me option you pass to showEditor

@yanghun0070
Copy link
Author

yanghun0070 commented Nov 30, 2023

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));
                }}
sample.mp4

@yanghun0070
Copy link
Author

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
Copy link
Owner

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

@maitrungduc1410
Copy link
Owner

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.

  • first sample: no change just trim, which should generate same video as original one
  • second sample: choose a time range and trim

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

copy_F7E84069-79B7-41FA-A93D-A2985A55513C.1.mp4

@yanghun0070
Copy link
Author

I'm getting the same error

1.mp4

@maitrungduc1410
Copy link
Owner

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

@maitrungduc1410
Copy link
Owner

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
Copy link
Author

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
Copy link
Owner

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

@maitrungduc1410
Copy link
Owner

Btw where did you add the code for saveVideoToGallery?

@yanghun0070
Copy link
Author

yanghun0070 commented Dec 1, 2023

@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
Copy link
Owner

fixed in 1.0.8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants