[FFmpeg-user] "Cannot allocate memory" error
Cley Faye
cleyfaye at gmail.com
Fri Mar 11 01:46:16 CET 2016
Hi,
I'm facing an unusual issue that seems caused by amix, but I'm not sure
about this at all.
I'm trying to merge the audio from a video file and an audio file, and
output a single video file with one video stream and one audio stream. I
stripped down the command to this:
> ffmpeg -i "in.mp4" -i "in.m4a" -filter_complex "[0:a][1:a]amix[outA]"
-map 0:0 -map [outA] out.mp4
(of course the command I intend to use have a lot more stuff going on, but
I get the error with just this command line).
And I get the following error message: "Cannot allocate memory"
The output:
ffmpeg version N-78990-g689211d Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-iconv --enable-libass --enable-libbluray
--enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype
--enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
--enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
--enable-librtmp --enable-libschroedinger --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg
--enable-lzma --enable-decklink --enable-zlib
libavutil 55. 19.100 / 55. 19.100
libavcodec 57. 28.100 / 57. 28.100
libavformat 57. 28.100 / 57. 28.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 39.102 / 6. 39.102
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[h264 @ 000001e2e394c6a0] Increasing reorder buffer to 1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : LP 37
date : 2016-03-10
encoder : Lavf57.27.100
Duration: 00:00:05.02, start: 0.000000, bitrate: 20188 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
bt709), 1920x1080 [SAR 1:1 DAR 16:9], 19953 kb/s, 60 fps, 60 tbr, 60k tbn,
120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 221 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'in.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
title : LP 37
date : 2016-03-10
encoder : Lavf57.27.100
Duration: 00:00:05.02, start: 0.021333, bitrate: 131 kb/s
Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
[libx264 @ 000001e2e43b1880] using SAR=1/1
[libx264 @ 000001e2e43b1880] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 000001e2e43b1880] profile High, level 4.2
[libx264 @ 000001e2e43b1880] 264 - core 148 r2665 a01e339 - H.264/MPEG-4
AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12
lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25
scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : LP 37
date : 2016-03-10
encoder : Lavf57.28.100
Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 60 fps, 15360 tbn, 60 tbc
(default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.28.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz,
stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc57.28.100 aac
Stream mapping:
Stream #0:1 (aac) -> amix:input0 (graph 0)
Stream #1:0 (aac) -> amix:input1 (graph 0)
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
amix (graph 0) -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
frame= 75 fps=0.0 q=31.0 size= 94kB time=00:00:00.30
bitrate=2557.8kbits/s speed= 0.6x
frame= 137 fps=137 q=31.0 size= 122kB time=00:00:01.32 bitrate=
757.3kbits/s speed=1.32x
frame= 199 fps=131 q=31.0 size= 156kB time=00:00:02.37 bitrate=
539.8kbits/s speed=1.55x
frame= 261 fps=129 q=31.0 size= 184kB time=00:00:03.39 bitrate=
444.4kbits/s speed=1.67x
Error while filtering: Cannot allocate memory
frame= 301 fps=117 q=-1.0 Lsize= 332kB time=00:00:05.01 bitrate=
542.1kbits/s speed=1.95x
video:243kB audio:80kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 2.847260%
[libx264 @ 000001e2e43b1880] frame I:2 Avg QP:21.55 size: 94650
[libx264 @ 000001e2e43b1880] frame P:77 Avg QP:19.49 size: 381
[libx264 @ 000001e2e43b1880] frame B:222 Avg QP:17.07 size: 134
[libx264 @ 000001e2e43b1880] consecutive B-frames: 1.3% 0.7% 1.0% 97.0%
[libx264 @ 000001e2e43b1880] mb I I16..4: 4.6% 84.7% 10.7%
[libx264 @ 000001e2e43b1880] mb P I16..4: 0.2% 0.3% 0.0% P16..4: 0.3%
0.0% 0.0% 0.0% 0.0% skip:99.1%
[libx264 @ 000001e2e43b1880] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.7%
0.0% 0.0% direct: 0.0% skip:99.3% L0:61.0% L1:38.6% BI: 0.4%
[libx264 @ 000001e2e43b1880] 8x8 transform intra:76.6% inter:57.3%
[libx264 @ 000001e2e43b1880] coded y,uvDC,uvAC intra: 16.0% 18.4% 14.5%
inter: 0.0% 0.1% 0.0%
[libx264 @ 000001e2e43b1880] i16 v,h,dc,p: 61% 35% 2% 2%
[libx264 @ 000001e2e43b1880] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 78% 4% 11% 1%
1% 1% 1% 2% 2%
[libx264 @ 000001e2e43b1880] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 22% 12% 4%
4% 4% 4% 4% 5%
[libx264 @ 000001e2e43b1880] i8c dc,h,v,p: 84% 6% 8% 2%
[libx264 @ 000001e2e43b1880] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001e2e43b1880] ref P L0: 79.6% 8.2% 9.7% 2.5%
[libx264 @ 000001e2e43b1880] ref B L0: 50.8% 47.8% 1.3%
[libx264 @ 000001e2e43b1880] ref B L1: 98.8% 1.2%
[libx264 @ 000001e2e43b1880] kb/s:395.90
[aac @ 000001e2e454a020] Qavg: 8753.953
Notice the "Cannot allocate memory" in the middle.
If I swap 0:a and 1:a in amix, I get a lot more errors:
> ffmpeg -i "in.mp4" -i "in.m4a" -filter_complex "[1:a][0:a]amix[outA]"
-map 0:0 -map [outA] out.mp4
ffmpeg version N-78990-g689211d Copyright (c) 2000-2016 the FFmpeg
developers
built with gcc 5.3.0 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads
--enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei0r
--enable-gnutls --enable-iconv --enable-libass --enable-libbluray
--enable-libbs2b --enable-libcaca --enable-libdcadec --enable-libfreetype
--enable-libgme --enable-libgsm --enable-libilbc --enable-libmodplug
--enable-libmfx --enable-libmp3lame --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
--enable-librtmp --enable-libschroedinger --enable-libsnappy
--enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame
--enable-libvidstab --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264
--enable-libx265 --enable-libxavs --enable-libxvid --enable-libzimg
--enable-lzma --enable-decklink --enable-zlib
libavutil 55. 19.100 / 55. 19.100
libavcodec 57. 28.100 / 57. 28.100
libavformat 57. 28.100 / 57. 28.100
libavdevice 57. 0.101 / 57. 0.101
libavfilter 6. 39.102 / 6. 39.102
libswscale 4. 0.100 / 4. 0.100
libswresample 2. 0.101 / 2. 0.101
libpostproc 54. 0.100 / 54. 0.100
[h264 @ 000001baef23c6a0] Increasing reorder buffer to 1
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'in.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : LP 37
date : 2016-03-10
encoder : Lavf57.27.100
Duration: 00:00:05.02, start: 0.000000, bitrate: 20188 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv,
bt709), 1920x1080 [SAR 1:1 DAR 16:9], 19953 kb/s, 60 fps, 60 tbr, 60k tbn,
120 tbc (default)
Metadata:
handler_name : VideoHandler
Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 221 kb/s (default)
Metadata:
handler_name : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'in.m4a':
Metadata:
major_brand : M4A
minor_version : 512
compatible_brands: isomiso2
title : LP 37
date : 2016-03-10
encoder : Lavf57.27.100
Duration: 00:00:05.02, start: 0.021333, bitrate: 131 kb/s
Stream #1:0(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz,
stereo, fltp, 128 kb/s (default)
Metadata:
handler_name : SoundHandler
[libx264 @ 000001baef2c9160] using SAR=1/1
[libx264 @ 000001baef2c9160] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 000001baef2c9160] profile High, level 4.2
[libx264 @ 000001baef2c9160] 264 - core 148 r2665 a01e339 - H.264/MPEG-4
AVC codec - Copyleft 2003-2016 - http://www.videolan.org/x264.html -
options: cabac=1 ref=3 deblock=1:0:0 analyse=0x3:0x113 me=hex subme=7 psy=1
psy_rd=1.00:0.00 mixed_ref=1 me_range=16 chroma_me=1 trellis=1 8x8dct=1
cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=12
lookahead_threads=2 sliced_threads=0 nr=0 decimate=1 interlaced=0
bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1
b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 keyint_min=25
scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0
qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to 'out.mp4':
Metadata:
major_brand : isom
minor_version : 512
compatible_brands: isomiso2avc1mp41
title : LP 37
date : 2016-03-10
encoder : Lavf57.28.100
Stream #0:0(eng): Video: h264 (libx264) ([33][0][0][0] / 0x0021),
yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 60 fps, 15360 tbn, 60 tbc
(default)
Metadata:
handler_name : VideoHandler
encoder : Lavc57.28.100 libx264
Side data:
cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz,
stereo, fltp, 128 kb/s (default)
Metadata:
encoder : Lavc57.28.100 aac
Stream mapping:
Stream #0:1 (aac) -> amix:input1 (graph 0)
Stream #1:0 (aac) -> amix:input0 (graph 0)
Stream #0:0 -> #0:0 (h264 (native) -> h264 (libx264))
amix (graph 0) -> Stream #0:1 (aac)
Press [q] to stop, [?] for help
Error while decoding stream #0:1: Cannot allocate memory
Last message repeated 63 times
frame= 73 fps=0.0 q=31.0 size= 93kB time=00:00:00.25
bitrate=2963.4kbits/s speed=0.511x
Error while decoding stream #0:1: Cannot allocate memory
Last message repeated 46 times
frame= 135 fps=132 q=31.0 size= 122kB time=00:00:01.30 bitrate=
767.5kbits/s speed=1.27x
Error while decoding stream #0:1: Cannot allocate memory
Last message repeated 49 times
frame= 197 fps=129 q=31.0 size= 154kB time=00:00:02.32 bitrate=
541.3kbits/s speed=1.52x
Error while decoding stream #0:1: Cannot allocate memory
Last message repeated 36 times
frame= 246 fps=121 q=31.0 size= 179kB time=00:00:03.15 bitrate=
463.9kbits/s speed=1.56x
Error while decoding stream #0:1: Cannot allocate memory
Last message repeated 36 times
frame= 298 fps=118 q=31.0 size= 198kB time=00:00:04.01 bitrate=
404.2kbits/s speed=1.59x
frame= 301 fps=107 q=-1.0 Lsize= 332kB time=00:00:05.03 bitrate=
540.1kbits/s speed=1.79x
video:243kB audio:80kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 2.844408%
[libx264 @ 000001baef2c9160] frame I:2 Avg QP:21.55 size: 94650
[libx264 @ 000001baef2c9160] frame P:77 Avg QP:19.49 size: 381
[libx264 @ 000001baef2c9160] frame B:222 Avg QP:17.07 size: 134
[libx264 @ 000001baef2c9160] consecutive B-frames: 1.3% 0.7% 1.0% 97.0%
[libx264 @ 000001baef2c9160] mb I I16..4: 4.6% 84.7% 10.7%
[libx264 @ 000001baef2c9160] mb P I16..4: 0.2% 0.3% 0.0% P16..4: 0.3%
0.0% 0.0% 0.0% 0.0% skip:99.1%
[libx264 @ 000001baef2c9160] mb B I16..4: 0.0% 0.0% 0.0% B16..8: 0.7%
0.0% 0.0% direct: 0.0% skip:99.3% L0:61.0% L1:38.6% BI: 0.4%
[libx264 @ 000001baef2c9160] 8x8 transform intra:76.6% inter:57.3%
[libx264 @ 000001baef2c9160] coded y,uvDC,uvAC intra: 16.0% 18.4% 14.5%
inter: 0.0% 0.1% 0.0%
[libx264 @ 000001baef2c9160] i16 v,h,dc,p: 61% 35% 2% 2%
[libx264 @ 000001baef2c9160] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 78% 4% 11% 1%
1% 1% 1% 2% 2%
[libx264 @ 000001baef2c9160] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 40% 22% 12% 4%
4% 4% 4% 4% 5%
[libx264 @ 000001baef2c9160] i8c dc,h,v,p: 84% 6% 8% 2%
[libx264 @ 000001baef2c9160] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 000001baef2c9160] ref P L0: 79.6% 8.2% 9.7% 2.5%
[libx264 @ 000001baef2c9160] ref B L0: 50.8% 47.8% 1.3%
[libx264 @ 000001baef2c9160] ref B L1: 98.8% 1.2%
[libx264 @ 000001baef2c9160] kb/s:395.90
[aac @ 000001baefca2660] Qavg: 8984.945
In both case, the output *seems* correct; however, increasing the
complexity of the filter_complex and the number of inputs cause ffmpeg to
stop prematurely without errors.
I'm not sure yet that this behavior and the error message depicted here are
related, but I don't think ffmpeg should output "Cannot allocate memory" in
such simple case.
More details:
- This is on windows, the 64-bit build from zeranoe.com
- The complete output with -loglevel debug can be found here:
http://pastebin.com/j25U616g
- The memory used by ffmpeg doesn't increase that much; around 450MB, which
stay stable from the beginning to the end of the encoding.
- The file themselves are available from http://cleyfaye.net/share/in.mp4
and http://cleyfaye.net/share/in.m4a
I might be doing something wrong, but I believe I stripped the command line
down enough to exclude that.
More information about the ffmpeg-user
mailing list