maitrungduc1410 / react-native-video-trim

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

Event returns 'Command failed with state COMPLETED and rc 1.null' when i finish trim #38

Closed mguerrero-exe closed 2 months ago

mguerrero-exe commented 2 months ago

I got this error in the logs when I try to trim a video, and Idk what happens, im using 'react-native-image-cropp-picker', and making sure the file is valid before trimming the video, but when I finish the trim, the editor just returns an error in the console:

{ 
  name: 'onError',
  message: 'Command failed with state COMPLETED and rc 1.null'
 }

Here I make sure the video is valid

if (type === 'video') {
  isValidVideo((filesFromPicker as ImageOrVideo).path).then((e) => console.log(e))
    showEditor((filesFromPicker as ImageOrVideo).path, {
    maxDuration: 30,
    saveToPhoto: false,
    enableSaveDialog: false
   })
}

Events:

useEffect(() => {
  const eventEmitter = new NativeEventEmitter(NativeModules.VideoTrim);

  const subscription = eventEmitter.addListener('VideoTrim', (e) => {
    switch (e.name) {
      case 'onShow': {
        console.log('onShowListener', e);
        break;
      }
      case 'onHide': {
        console.log('onHide', e);
        break;
      }
      case 'onStartTrimming': {
        console.log('onStartTrimming', e);
        break;
      }
      case 'onFinishTrimming': {
        console.log('onFinishTrimming', e);
        break;
      }
      case 'onCancelTrimming': {
        console.log('onCancelTrimming', e);
        break;
      }
      case 'onError': {
        console.log('onError', e);
        break;
      }
    }
  })
 return () => {
    subscription.remove()
  }
}, [])

It should be noted that I am not using any other library that could affect its functionality, I do not use any FFMPEG kit either, so the one that comes with the default trimmer library is the one that is in use.

maitrungduc1410 commented 2 months ago

Are you using real device?

If not, pls always use real device for that

mguerrero-exe commented 2 months ago

No, I'm using an emulator, I thought using real devices was only necessary for IOS, and I'm testing on an Android emulato, but I'll test on a real device...

maitrungduc1410 commented 2 months ago

I'm gonna update the README and clearly mention this, it's required to run your app on real device for both Android and iOS

mguerrero-exe commented 2 months ago

Solved!!! Thanks you!

chetanbhadarka commented 2 months ago

@maitrungduc1410, I'm getting same error on real device ANDROID. I didn't tested on emulator as you mention in README file so. I also check first for valid-video. can you explain bit more about how isValidVideo verify.

here is my code. need help.

onPress={() => {
  isValidVideo(allVideos[0]?.realPath || '').then(res => {
    if (res) {
      showEditor(allVideos[0]?.realPath || '', {
        maxDuration: 20,
      }).catch(e => console.log('eror => ', e));
    }
  });
}}
onError {"message": "Command failed with state COMPLETED and rc 1.null", "name": "onError"}
maitrungduc1410 commented 2 months ago

IsValidVideo is based on platform function to check if a file is actual video, you can check in native code, it's simple logics

maitrungduc1410 commented 2 months ago

Btw, is it possible for you to provide the input video you're using to test, I'll try to reproduce from my end

chetanbhadarka commented 2 months ago

Btw, is it possible for you to provide the input video you're using to test, I'll try to reproduce from my end

I'm using react-native-multiple-image-picker for pick video from internal storage of device.

here is Response object.

I checked with "path" first and then with "realPath" as I'm testing on android device so. In "IsValidVideo" function for both I'm getting "true" but when Proceed after trimming video getting error.

maitrungduc1410 commented 2 months ago

You're testing on android right?

What do you mean by internal store?

Can you try move it to Photos and try again?

chetanbhadarka commented 2 months ago

You're testing on android right?

What do you mean by internal store?

Can you try move it to Photos and try again?

Yes in android. Internal storage means I'm not using any SD card. But i'll try it with recorded video from Camera and let you update here.

chetanbhadarka commented 2 months ago

@maitrungduc1410, I've tested with recorded video from Camera and it return "onFinishTrimming". it mean trim works.

but why not working for other path. I have a video in download folder (downloaded from browser, so) but getting error after trim proceed. can you please suggest me how to figure out this thing.

maitrungduc1410 commented 2 months ago

@chetanbhadarka

I'm trying on Android 9, API 28, anything I select in Gallary App works. In the app I also try with Downloads folder which contains downloaded video from browser

chetanbhadarka commented 2 months ago

@chetanbhadarka

I'm trying on Android 9, API 28, anything I select in Gallary App works. In the app I also try with Downloads folder which contains downloaded video from browser

Okay, I have Android 11, API 30.

Well thank you for your support, I'll test with other file provider and let you know.