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 323 forks source link

RNVideoTrimmer.swift Fatal error > Unexpectedly found nil while unwrapping an Optional value #347

Open oguzhnatly opened 2 years ago

oguzhnatly commented 2 years ago

Current Behavior

I was able to obtain ProcessingManager.getVideoInfo and the function returns a successful result, however when I try to compress the file, I receive Xcode errors and the app crashes unexpectedly.

I believe I have successfully linked the required libraries to our Xcode, otherwise there would be an error at runtime.

Expected Behavior

I could compress the file as expected.

React Native Code

Ekran Resmi 2021-08-20 12 40 11

Xcode Errors:

EXC_BREAKPOINT: Fatal error > Unexpectedly found nil while unwrapping an Optional value

Ekran Resmi 2021-08-20 12 43 29 Ekran Resmi 2021-08-20 12 54 58

2021-08-20 12:35:43.692099+0300 xapp[2849:509003] [javascript] begin compressing file:///var/mobile/Containers/Data/Application/BC623DFB-4F44-4D77-AB9B-3C5BCC633C30/tmp/Little1080p.mov 2021-08-20 12:35:43.709960+0300 xapp[2849:509003] [javascript] { origin: { bitrate: 2858034, duration: 17.98, size: { width: 1920, height: 976 }, frameRate: 25 } } 2021-08-20 12:35:44.371166+0300 xapp[2849:507936] VERBOSE: registerUser:waitingForApnsResponse: 0 2021-08-20 12:35:44.371509+0300 xapp[2849:507936] VERBOSE: registerUser:initializationTime: 2021-08-20 09:35:11 +0000 2021-08-20 12:35:44.371611+0300 xapp[2849:507936] VERBOSE: registerUserNow 2021-08-20 12:35:44.371765+0300 xapp[2849:508931] VERBOSE: registerUserInternal 2021-08-20 12:35:44.372269+0300 xapp[2849:508931] VERBOSE: shouldRegisterNow:waitingForOneSReg: 0 2021-08-20 12:35:44.372399+0300 xapp[2849:508931] VERBOSE: shouldRegisterNow:isImmediatePlayerCreateOrOnSession: 0 2021-08-20 12:35:44.372492+0300 xapp[2849:508931] VERBOSE: shouldRegisterNow:isOnSessionSuccessfulForCurrentState: 0 2021-08-20 12:35:44.372613+0300 xapp[2849:508931] DEBUG: shouldRegisterNow: lastTimeClosed: 1629452114.563886 xapp/RNVideoTrimmer.swift:698: Fatal error: Unexpectedly found nil while unwrapping an Optional value 2021-08-20 12:35:46.624982+0300 xapp[2849:509375] xapp/RNVideoTrimmer.swift:698: Fatal error: Unexpectedly found nil while unwrapping an Optional value 2021-08-20 12:35:57.211134+0300 xapp[2849:507936] VERBOSE: registerUser:waitingForApnsResponse: 0 2021-08-20 12:35:57.211380+0300 xapp[2849:507936] VERBOSE: registerUser:initializationTime: 2021-08-20 09:35:11 +0000 (lldb)

Your Environment

Xcode Version 12.5.1 Device 1: iPhone 12 Pro (iOS 14.5) Device 2: iPhone 11 (iOS 15.0)

software version
react-native-video-processing ^2.0.0
react-native ^0.64.2
node v16.6.1
SilKeshari commented 2 years ago

Any update on this ? getting same error.

thatgriffith commented 2 years ago

Also getting this error. Works fine on Android though. getVideoInfo works fine on iOS and Android.

thatgriffith commented 2 years ago

Okay, I finally found out what the problem was for me.

The response from ProcessingManager.compress differs on Android and iOS. On Android you receive an object with source (just like the image). On iOS, the result is only string (the path).

Also, ProcessingManager.getPreviewForSecond was also causing errors so I deleted (didn't really need it).

Hopefully, this solves some headaches. 🙂

jpike88 commented 2 years ago

@shahen94 I just ran into this problem