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 app crashing ProcessingManager.compress #104

Closed isAlmogK closed 6 years ago

isAlmogK commented 6 years ago

My app keeps crashing when I try to run ProcessingManager.compress

Maybe my source is incorrect here is my code

 ProcessingManager.compress(response.uri, videoOptions) 
                    .then((data) => console.log(data));

Also how do you catch errors?

isAlmogK commented 6 years ago

Here is the error that I'm now getting

console.js:26 Possible Unhandled Promise Rejection (id: 0):
Error: compress error: failed. ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers  built with gcc 4.8 (GCC)  configuration: --target-os=linux --cross-prefix=/Users/kesha/Projects/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/Users/kesha/Projects/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/Users/kesha/Projects/ffmpeg-android/ffmpeg-pkg-config --prefix=/Users/kesha/Projects/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/Users/kesha/Projects/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/Users/kesha/Projects/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=  libavutil      55. 58.100 / 55. 58.100  libavcodec     57. 89.100 / 57. 89.100  libavformat    57. 71.100 / 57. 71.100  libavdevice    57.  6.100 / 57.  6.100  libavfilter     6. 82.100 /  6. 82.100  libswscale      4.  6.100 /  4.  6.100  libswresample   2.  7.100 /  2.  7.100  libpostproc    54.  5.100 / 54.  5.100content://media/external/video/media/8272: Protocol not foundDid you mean file:content://media/external/video/media/8272?
Error: compress error: failed. ffmpeg version 3.3 Copyright (c) 2000-2017 the FFmpeg developers  built with gcc 4.8 (GCC)  configuration: --target-os=linux --cross-prefix=/Users/kesha/Projects/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/Users/kesha/Projects/ffmpeg-android/toolchain-android/sysroot --enable-pic --enable-libx264 --enable-libass --enable-libfreetype --enable-libfribidi --enable-libmp3lame --enable-fontconfig --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-gpl --enable-yasm --disable-doc --disable-shared --enable-static --pkg-config=/Users/kesha/Projects/ffmpeg-android/ffmpeg-pkg-config --prefix=/Users/kesha/Projects/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/Users/kesha/Projects/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/Users/kesha/Projects/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags=  libavutil      55. 58.100 / 55. 58.100  libavcodec     57. 89.100 / 57. 89.100  libavformat    57. 71.100 / 57. 71.100  libavdevice    57.  6.100 / 57.  6.100  libavfilter     6. 82.100 /  6. 82.100  libswscale      4.  6.100 /  4.  6.100  libswresample   2.  7.100 /  2.  7.100  libpostproc    54.  5.100 / 54.  5.100content://media/external/video/media/8272: Protocol not foundDid you mean file:content://media/external/video/media/8272?
    at createErrorFromErrorData (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:1745:15)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:1702:25
    at MessageQueue.__invokeCallback (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:2049:16)
    at http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:1842:15
    at MessageQueue.__guard (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:1980:9)
    at MessageQueue.invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.android.bundle?platform=android&dev=true&hot=false&minify=false:1841:13)
    at http://localhost:8081/debuggerWorker.js:72:58
isAlmogK commented 6 years ago

I'm closing this have it working using path and not uri

shahen94 commented 6 years ago

Hi @AlmogRnD ! Your video URI is incorrect - so we should check it

So what we should do:

  1. We should check if file protocol starts with content then parse it as URI (URI.parse(source))
  2. pass it to ffmpeg in correct format https://github.com/shahen94/react-native-video-processing/blob/master/android/src/main/java/com/shahenlibrary/Trimmer/Trimmer.java#L421

Unfortunately i have no time to work on this issue, but if you'll fix and open PR - I'll merge it