react-native-video-processing: Out of Memory in Android when calling ProcessManager.compress
I cant seem to compress a 10 sec video using ProcessManager.compress in android.,
This is how I am trying to do it:
componentWillMount() {
> const options = {
> width: 500,
> height: 500,
> bitrateMultiplier: 3, // iOS only
> saveToCameraRoll: true, // default is false, iOS only
> saveWithCurrentDate: true, // default is false, iOS only
> minimumBitrate: 300000, // iOS only
> removeAudio: false, // default is false
> };
> console.log(this.props.navigation.state.params.videoData.path);
>
> const me = ProcessingManager.compress(this.props.navigation.state.params.videoData.path, options);
> console.log(me);
}
this.props.navigation.state.params.videoData.path is a string of value ‘file:///storage/emulated/0/Movies/VID_20171110_191714.mp4’
This is the error I get:
Error: compress error: failed. ffmpeg version 3.3.5 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-libx264 --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-yasm --disable-doc --disable-shared --enable-static --enable-nonfree --disable-network --enable-gpl --enable-ffmpeg --enable-small --disable-filters --enable-filter=copy --enable-filter=trim --enable-filter=crop --enable-filter=scale --enable-filter=format --pkg-config=/Users/kesha/Projects/ffmpeg-android/ffmpeg-3.3-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-cxxflags= --extra-libs='-lx264 -lm' 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.100Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:///storage/emulated/0/Movies/VID_20171110_191714.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2017-11-10T16:17:19.000000Z com.android.version: 6.0.1 Duration: 00:00:04.80, start: 0.000000, bitrate: 2120 kb/s Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 800x450, 1906 kb/s, 16.46 fps, 16.58 tbr, 90k tbn, 180k tbc (default) Metadata: rotate : 270 creation_time : 2017-11-10T16:17:19.000000Z handler_name : VideoHandle Side data: displaymatrix: rotation of 90.00 degrees Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default) Metadata: creation_time : 2017-11-10T16:17:19.000000Z handler_name : SoundHandleStream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native))Press [q] to stop, [?] for helpframe= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A Error reinitializing filters!Failed to inject frame into filter network: Out of memoryError while processing the decoded data for stream #0:0[aac @ 0xb60c5c00] Qavg: 22480.779[aac @ 0xb60c5c00] 2 frames left in the queue on closingConversion failed! at createErrorFromErrorData (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1807:15) at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1760:25 at MessageQueue.__invokeCallback (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2118:16) at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1935:16 at MessageQueue.__guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2053:9) at MessageQueue.invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1934:12) at http://localhost:8081/debugger-ui/debuggerWorker.js:72:58
code
:
"EUNSPECIFIED"
framesToPop
:
1
message
:
"compress error: failed. ffmpeg version 3.3.5 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-libx264 --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-yasm --disable-doc --disable-shared --enable-static --enable-nonfree --disable-network --enable-gpl --enable-ffmpeg --enable-small --disable-filters --enable-filter=copy --enable-filter=trim --enable-filter=crop --enable-filter=scale --enable-filter=format --pkg-config=/Users/kesha/Projects/ffmpeg-android/ffmpeg-3.3-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-cxxflags= --extra-libs='-lx264 -lm' 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.100Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:///storage/emulated/0/Movies/VID_20171110_191714.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2017-11-10T16:17:19.000000Z com.android.version: 6.0.1 Duration: 00:00:04.80, start: 0.000000, bitrate: 2120 kb/s Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 800x450, 1906 kb/s, 16.46 fps, 16.58 tbr, 90k tbn, 180k tbc (default) Metadata: rotate : 270 creation_time : 2017-11-10T16:17:19.000000Z handler_name : VideoHandle Side data: displaymatrix: rotation of 90.00 degrees Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default) Metadata: creation_time : 2017-11-10T16:17:19.000000Z handler_name : SoundHandleStream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native))Press [q] to stop, [?] for helpframe= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A Error reinitializing filters!Failed to inject frame into filter network: Out of memoryError while processing the decoded data for stream #0:0[aac @ 0xb60c5c00] Qavg: 22480.779[aac @ 0xb60c5c00] 2 frames left in the queue on closingConversion failed!"
stack
:
"Error: compress error: failed. ffmpeg version 3.3.5 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-libx264 --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-yasm --disable-doc --disable-shared --enable-static --enable-nonfree --disable-network --enable-gpl --enable-ffmpeg --enable-small --disable-filters --enable-filter=copy --enable-filter=trim --enable-filter=crop --enable-filter=scale --enable-filter=format --pkg-config=/Users/kesha/Projects/ffmpeg-android/ffmpeg-3.3-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-cxxflags= --extra-libs='-lx264 -lm' 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.100Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'file:///storage/emulated/0/Movies/VID_20171110_191714.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2017-11-10T16:17:19.000000Z com.android.version: 6.0.1 Duration: 00:00:04.80, start: 0.000000, bitrate: 2120 kb/s Stream #0:0(eng): Video: h264 (avc1 / 0x31637661), yuv420p, 800x450, 1906 kb/s, 16.46 fps, 16.58 tbr, 90k tbn, 180k tbc (default) Metadata: rotate : 270 creation_time : 2017-11-10T16:17:19.000000Z handler_name : VideoHandle Side data: displaymatrix: rotation of 90.00 degrees Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 256 kb/s (default) Metadata: creation_time : 2017-11-10T16:17:19.000000Z handler_name : SoundHandleStream mapping: Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:1 -> #0:1 (aac (native) -> aac (native))Press [q] to stop, [?] for helpframe= 0 fps=0.0 q=0.0 size= 0kB time=-577014:32:22.77 bitrate= -0.0kbits/s speed=N/A Error reinitializing filters!Failed to inject frame into filter network: Out of memoryError while processing the decoded data for stream #0:0[aac @ 0xb60c5c00] Qavg: 22480.779[aac @ 0xb60c5c00] 2 frames left in the queue on closingConversion failed!↵ at createErrorFromErrorData (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1807:15)↵ at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1760:25↵ at MessageQueue.__invokeCallback (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2118:16)↵ at http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1935:16↵ at MessageQueue.__guard (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:2053:9)↵ at MessageQueue.invokeCallbackAndReturnFlushedQueue (http://localhost:8081/index.bundle?platform=android&dev=true&minify=false:1934:12)↵ at http://localhost:8081/debugger-ui/debuggerWorker.js:72:58"
About this issue
- Original URL
- State: open
- Created 7 years ago
- Reactions: 10
- Comments: 23 (10 by maintainers)
issue still persists on Android Jellybean
9.556 2947-3001/? I/ReactNativeJS: { [Error: compress error: failed. /data/data/com.sample.prod/files/ffmpeg[1]: syntax error: '��4��4' unexpected] framesToPop: 1, code: 'EUNSPECIFIED' }Facing the same issue. Tried out the master branch, as @shahen94 mentions a few comments up, (latest commit as of writing: f57addffcf94c97255f7622bfc18ceec53d644ed) and bug is still there: app is crashing on Android with an “out of memory” exception.
Full crash log:
Error: compressing image - compress error: failed. ffmpeg version 3.3.5 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-libx264 --enable-pthreads --disable-debug --disable-ffserver --enable-version3 --enable-hardcoded-tables --disable-ffplay --disable-ffprobe --enable-yasm --disable-doc --disable-shared --enable-static --enable-nonfree --disable-network --enable-gpl --enable-ffmpeg --enable-small --disable-filters --enable-filter=copy --enable-filter=trim --enable-filter=crop --enable-filter=scale --enable-filter=format --pkg-config=/Users/kesha/Projects/ffmpeg-android/ffmpeg-3.3-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-cxxflags= --extra-libs='-lx264 -lm' 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.100Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/storage/emulated/0/DCIM/Camera/VID_20180205_081711.mp4': Metadata: major_brand : mp42 minor_version : 0 compatible_brands: isommp42 creation_time : 2018-02-05T04:17:11.000000Z location : +00.0000+000.0000/ location-eng : +00.0000+000.0000/ com.android.version: 8.1.0 Duration: 00:00:30.57, start: 0.000000, bitrate: 21770 kb/s Stream #0:0(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, mono, fltp, 96 kb/s (default) Metadata: creation_time : 2018-02-05T04:17:11.000000Z handler_name : SoundHandle Stream #0:1(eng): Video: h264 (avc1 / 0x31637661), yuvj420p(pc, smpte170m), 1920x1080, 21889 kb/s, SAR 1:1 DAR 16:9, 29.90 fps, 30 tbr, 90k tbn, 180k tbc (default) Metadata: rotate : 90 creation_time : 2018-02-05T04:17:11.000000Z handler_name : VideoHandle Side data: displaymatrix: rotation of -90.00 degreesStream mapping: Stream #0:1 -> #0:0 (h264 (native) -> h264 (libx264)) Stream #0:0 -> #0:1 (aac (native) -> aac (native))Press [q] to stop, [?] for helpError reinitializing filters!Failed to inject frame into filter network: Out of memoryError while processing the decoded data for stream #0:1[aac @ 0xefc8ec00] Qavg: 4409.910[aac @ 0xefc8ec00] 2 frames left in the queue on closingConversion failed!I believe the important lines are these:
Failed to inject frame into filter network: Out of memoryError while processing the decoded data for stream #0:1[aac @ 0xefc8ec00] Qavg: 4409.910[aac @ 0xefc8ec00] 2 frames left in the queue on closingConversion failed!
@shahen94 , confirming that it works properly with the version from master 😃
@amberv0 please use sources from the master branch