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.24k stars 321 forks source link

When trimming, giving a value greater than 0 to startTime crashes the app #353

Closed medmo7 closed 2 years ago

medmo7 commented 2 years ago

Current Behavior

After doing a screen record a want the user to be able to trim the video. Trimming from the end works fine, but when trimming the start the app crashes.

Expected Behavior

The video is trimmed

Your Environment

software version
react-native-video-processing 2.0.0
react-native 0.64.2
node 16.11.0

The error from Android studio

2021-11-26 17:30:19.136 3956-5862/com.canvasrec E/unknown:ReactNative: Exception in native call
    java.lang.NumberFormatException: s == null
        at java.lang.Integer.parseInt(Integer.java:577)
        at java.lang.Integer.parseInt(Integer.java:650)
        at com.shahenlibrary.Trimmer.Trimmer.getVideoInfo(Trimmer.java:253)
        at com.shahenlibrary.Trimmer.TrimmerManager.getVideoInfo(TrimmerManager.java:64)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:372)
        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:151)
        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
        at android.os.Looper.loop(Looper.java:236)

The trimming code

 async trimVideo() {
        try {
            this.setState({ loading: true }, async () => { 
                const options = {
                    // startTime: this.state.trimStart,
                    startTime: 1,
                    endTime: this.state.trimEnd,
                    // quality: VideoPlayer.Constants.quality.QUALITY_1280x720, // iOS only
                    // saveToCameraRoll: true, // default is false // iOS only
                    // saveWithCurrentDate: true, // default is false // iOS only
                };

                ProcessingManager.trim(this.state.source, options) // like VideoPlayer trim options
                    .then((data) => {
                        console.log(data)
                        this.setState({ loading: false, source: data }, () => this.getSourceInfos())
                        this.props.updateVideoSource(data)
                        this.props.updateModalStep(UPLOAD_STEP.uploadChoice)
                        this.props.saveVideoQuestion(data, UPLOAD_STEP.uploadChoice)
                    })
                    .catch(error => console.log('error in trimVideo', error));
                })
        } catch (error) {
            console.log('error in trimVideo', error)
        }
    }
medmo7 commented 2 years ago

I found the issue, it's not related to the trim function sorry.

nguyen95 commented 1 year ago

Hey @medmo7, I face the same issue. How can you resolved this?

Pradeep7909 commented 3 weeks ago

Hey @medmo7, I face the same issue. How can you resolved this?

Hey had you found the solution for these??