shahen94 / react-native-video-processing

Native Video editing/trimming/compressing :movie_camera: library for React-Native
https://shahen94.github.io/react-native-video-processing/
MIT License
1.25k stars 325 forks source link

[Android] Attempt to invoke virtual method 'int android.graphics.Bitmap.getWidth()' on a null object reference #82

Closed zachrnolan closed 7 years ago

zachrnolan commented 7 years ago

RN 0.45.1

onCaptureMedia(mediaData) {
    console.log('mediaData: ', mediaData)
    const maximumSize = { width: 1080, height: 1080 };
    ProcessingManager.getPreviewForSecond(mediaData.path, 4, maximumSize, 'JPEG')
      .then(thumbnail => {
        console.log('previewForSecond: ', thumbnail)
        this.props.dispatch(PostReactionState.videoRecorded(mediaData.path, thumbnail))
      })
  },

I get a console.log for mediaData with a valid path to the video file. I never see the console.log for previewForSecond.

This works fine on iOS.

image

shahen94 commented 7 years ago

I guess your video is very short < 4sec is it right ?

zachrnolan commented 7 years ago

@shahen94 you're right, I think it was right around 4 seconds. I tried a longer video and it seems to work fine. I do notice that android doesn't give me a width/height though. I'm using a Samsung S7.

shahen94 commented 7 years ago

do you mean that the ProcessingManager.getVideoInfo() doesn't give width/height ?

zachrnolan commented 7 years ago

ProcessingManager.getPreviewForSecond will return an object with uri, width, height on iOS. However, on Android, it returns uri, but width/height are undefined.

shahen94 commented 7 years ago

Yes - that's right. We're not sending it from native https://github.com/shahen94/react-native-video-processing/blob/master/android/src/main/java/com/shahenlibrary/Trimmer/Trimmer.java#L360

zachrnolan commented 7 years ago

Got it, is this something that will be added in the future? I can close this task as it's unrelated.

shahen94 commented 7 years ago

it's a very simple feature, but i'll prefer to use getVideoInfo since it will give you what you need.

zachrnolan commented 7 years ago

Ok, I'll check that method out for now. Thanks for your help!