bravobit / FFmpeg-Android

FFMpeg/FFprobe compiled for Android
https://bravobit.nl/
MIT License
741 stars 176 forks source link

Error while filtering: Out of memory #17

Closed vincent-paing closed 6 years ago

vincent-paing commented 6 years ago

I'm trying to mix multiple audio into one audio sequence with each having different delay. The command looks like.

./ffmpeg -i ./drum2.wav -filter_complex "[0]adelay=651|651[s0];[0]adelay=2576|2576[s1];[0]adelay=2700|2700[s2];[s0][s1][s2]amix=3[mixout]" -map "[mixout]" -y result.mp3

It runs successfully and output correct file when I it from my PC's terminal. Implementing the same thing in an Android app throw out of memory error during filter process(Testing on Xiaomi Mi A1 with Android Oreo). Is the NDK the only way to use without memory limitation or am I missing something? The complete log in my Android:

ffmpeg version n3.0.1 Copyright (c) 2000-2016 the FFmpeg developers built with gcc 4.8 (GCC) configuration: --target-os=linux --cross-prefix=/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/bin/arm-linux-androideabi- --arch=arm --cpu=cortex-a8 --enable-runtime-cpudetect --sysroot=/home/vagrant/SourceCode/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=/home/vagrant/SourceCode/ffmpeg-android/ffmpeg-pkg-config --prefix=/home/vagrant/SourceCode/ffmpeg-android/build/armeabi-v7a --extra-cflags='-I/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/include -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=2 -fno-strict-overflow -fstack-protector-all' --extra-ldflags='-L/home/vagrant/SourceCode/ffmpeg-android/toolchain-android/lib -Wl,-z,relro -Wl,-z,now -pie' --extra-libs='-lpng -lexpat -lm' --extra-cxxflags= libavutil 55. 17.103 / 55. 17.103 libavcodec 57. 24.102 / 57. 24.102 libavformat 57. 25.100 / 57. 25.100 libavdevice 57. 0.101 / 57. 0.101 libavfilter 6. 31.100 / 6. 31.100 libswscale 4. 0.100 / 4. 0.100 libswresample 2. 0.101 / 2. 0.101 libpostproc 54. 0.100 / 54. 0.100 Input #0, ogg, from '/sdcard/drum.ogg': Duration: 00:00:02.02, start: 0.000000, bitrate: 89 kb/s Stream #0:0: Audio: vorbis, 44100 Hz, stereo, fltp, 80 kb/s Output #0, mp3, to '/sdcard/audioMerged.mp3': Metadata: TSSE : Lavf57.25.100 Stream #0:0: Audio: mp3 (libmp3lame), 44100 Hz, stereo, fltp (default) Metadata: encoder : Lavc57.24.102 libmp3lame Stream mapping: Stream #0:0 (vorbis) -> adelay Stream #0:0 (vorbis) -> adelay Stream #0:0 (vorbis) -> adelay amix -> Stream #0:0 (libmp3lame) Press [q] to stop, [?] for help size= 22kB time=00:00:01.35 bitrate= 131.8kbits/s speed= 2.7x
size= 40kB time=00:00:02.53 bitrate= 130.1kbits/s speed=2.48x
Error while filtering: Out of memory size= 43kB time=00:00:02.71 bitrate= 129.9kbits/s speed=2.44x
video:0kB audio:43kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.576507%

vincent-paing commented 6 years ago

I've been debugging and I have trace it to the error showing up on using 'amix'.

Brianvdb commented 6 years ago

As I can see in your log you're not using this library but the WritingMinds one.

Nevertheless, Out of memory could also indicate something else is wrong e.g. with your command or files. See for instance this issue: https://stackoverflow.com/questions/42159407/amix-filter-in-ffmpeg-fails-depending-on-the-mp3-inputs

vincent-paing commented 6 years ago

Putting the longest track as first input works. Thanks A LOT for the link.