ffmpeg: perdita audio durante la sovrapposizione di video di diverse lunghezze


1

Ho due video di diversa lunghezza, ciascuno con audio stereo, che ho sovrapposto usando ffmpeg. Ho assegnato l'audio dai due video al canale sinistro e destro, rispettivamente, del video in uscita.

Ecco il comando che sto usando:

ffmpeg -i v1.mp4 -i v2.mp4 -filter_complex "amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3;blend=all_expr='A*0.5+B*0.5'" output.mp4

Il problema è che ciò interrompe l'audio di entrambi i video di input dopo l'interruzione della riproduzione del video più corto, il che è un comportamento documentato per il amergefiltro. Inoltre, sputa molti di questi errori -

Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory

- sebbene completi l'elaborazione. Ho provato semplicemente a tralasciare il filtro amerge

 ffmpeg -i v1.mp4 -i v2.mp4 -filter_complex "pan=stereo|c0<c0+c1|c1<c2+c3;blend=all_expr='A*0.5+B*0.5'" output.mp4

ma l'output non include l'audio del secondo video. Come sarebbe fatto correttamente? Ci scusiamo per la domanda noob, ho iniziato a usare ffmpeg questa settimana.

Grazie per eventuali suggerimenti.

[Modifica] Ecco l'output con i messaggi di errore per il comando sopra menzionato:

C:\Users\admin\Downloads\ffmpeg-20170110-f48b6b8-win64-static\ffmpeg-20170110-f4 8b6b8-win64-static\bin>ffmpeg -i v01.mp4 -i v02.mp4 -filter_complex "amerge=inpu ts=2,pan=stereo|c1<c0+c1|c0<c2+c3;blend=all_expr='A*0.5+B*0.5'" out1.mp4 > outpu t.txt ffmpeg version N-83034-gf48b6b8 Copyright (c) 2000-2017 the FFmpeg developers built with gcc 5.4.0 (GCC) configuration: --enable-gpl --enable-version3 --enable-dxva2 --enable-libmfx - -enable-nvenc --enable-avisynth --enable-bzlib --enable-fontconfig --enable-frei 0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray --enable-li bbs2b --enable-libcaca --enable-libfreetype --enable-libgme --enable-libgsm --en able-libilbc --enable-libmodplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenh264 --enable-libopenjpeg --enable-li bopus --enable-librtmp --enable-libsnappy --enable-libsoxr --enable-libspeex --e nable-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 --e nable-lzma --enable-decklink --enable-zlib libavutil 55. 43.100 / 55. 43.100 libavcodec 57. 71.100 / 57. 71.100 libavformat 57. 62.100 / 57. 62.100 libavdevice 57. 2.100 / 57. 2.100 libavfilter 6. 68.100 / 6. 68.100 libswscale 4. 3.101 / 4. 3.101 libswresample 2. 4.100 / 2. 4.100 libpostproc 54. 2.100 / 54. 2.100 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'v01.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.62.100 location-eng : +37.3789-005.9891/ location : +37.3789-005.9891/ Duration: 00:00:05.02, start: 0.000000, bitrate: 4760 kb/s Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 , 4642 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default) Metadata: handler_name : VideoHandler Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt p, 122 kb/s (default) Metadata: handler_name : SoundHandler Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'v02.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.62.100 Duration: 00:00:15.02, start: 0.000000, bitrate: 3766 kb/s Stream #1:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 , 3632 kb/s, 29.97 fps, 29.97 tbr, 30k tbn, 59.94 tbc (default) Metadata: handler_name : VideoHandler Stream #1:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, flt p, 126 kb/s (default) Metadata: handler_name : SoundHandler File 'out1.mp4' already exists. Overwrite ? [y/N] y [Parsed_amerge_0 @ 0000000002325e80] No channel layout for input 1 [Parsed_amerge_0 @ 0000000002325e80] Input channel layouts overlap: output layou t will be determined by the number of distinct input channels [libx264 @ 0000000001bff560] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2 [libx264 @ 0000000001bff560] profile High, level 4.0 [libx264 @ 0000000001bff560] 264 - core 148 r2744 b97ae06 - H.264/MPEG-4 AVC cod ec - Copyleft 2003-2016 - http://www.videolan.org/x264.html - options: cabac=1 r ef=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_pski p=1 chroma_qp_offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 deci mate=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=2 5 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=crf mbtree=1 crf=23.0 qcomp=0.6 0 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00 Output #0, mp4, to 'out1.mp4': Metadata: major_brand : isom minor_version : 512 compatible_brands: isomiso2avc1mp41 encoder : Lavf57.62.100 Stream #0:0: Audio: aac (LC) ([64][0][0][0] / 0x0040), 48000 Hz, stereo, flt p, 128 kb/s (default) Metadata: encoder : Lavc57.71.100 aac Stream #0:1: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 1920x1 080, q=-1--1, 29.97 fps, 30k tbn, 29.97 tbc (default) Metadata: encoder : Lavc57.71.100 libx264 Side data: cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1 Stream mapping: Stream #0:0 (h264) -> blend:top Stream #0:1 (aac) -> amerge:in0 Stream #1:0 (h264) -> blend:bottom Stream #1:1 (aac) -> amerge:in1 pan -> Stream #0:0 (aac) blend -> Stream #0:1 (libx264) Press [q] to stop, [?] for help frame= 5 fps=0.0 q=0.0 size= 0kB time=00:00:00.23 bitrate= 0.0kbits/s frame= 10 fps=9.5 q=0.0 size= 0kB time=00:00:00.38 bitrate= 0.0kbits/s frame= 16 fps=9.7 q=0.0 size= 0kB time=00:00:00.60 bitrate= 0.0kbits/s frame= 22 fps=9.8 q=0.0 size= 0kB time=00:00:00.79 bitrate= 0.0kbits/s frame= 28 fps=9.9 q=0.0 size= 0kB time=00:00:00.98 bitrate= 0.0kbits/s frame= 34 fps= 10 q=0.0 size= 0kB time=00:00:01.19 bitrate= 0.0kbits/s frame= 39 fps= 10 q=0.0 size= 0kB time=00:00:01.36 bitrate= 0.0kbits/s frame= 44 fps= 10 q=0.0 size= 0kB time=00:00:01.51 bitrate= 0.0kbits/s frame= 46 fps=9.0 q=0.0 size= 0kB time=00:00:01.60 bitrate= 0.0kbits/s frame= 51 fps=9.0 q=29.0 size= 42kB time=00:00:01.75 bitrate= 197.4kbits/ frame= 55 fps=8.8 q=29.0 size= 147kB time=00:00:01.90 bitrate= 633.2kbits/ frame= 59 fps=8.7 q=29.0 size= 220kB time=00:00:02.02 bitrate= 888.5kbits/ frame= 63 fps=8.5 q=29.0 size= 288kB time=00:00:02.15 bitrate=1092.1kbits/ frame= 67 fps=8.4 q=29.0 size= 360kB time=00:00:02.28 bitrate=1289.4kbits/ frame= 71 fps=8.3 q=29.0 size= 435kB time=00:00:02.43 bitrate=1465.1kbits/ frame= 75 fps=8.2 q=29.0 size= 514kB time=00:00:02.56 bitrate=1642.1kbits/ frame= 79 fps=8.1 q=29.0 size= 577kB time=00:00:02.69 bitrate=1757.4kbits/ frame= 83 fps=8.1 q=29.0 size= 630kB time=00:00:02.81 bitrate=1831.7kbits/ frame= 87 fps=8.0 q=29.0 size= 695kB time=00:00:02.96 bitrate=1917.5kbits/ frame= 91 fps=8.0 q=29.0 size= 760kB time=00:00:03.09 bitrate=2011.4kbits/ frame= 95 fps=8.0 q=29.0 size= 822kB time=00:00:03.22 bitrate=2088.1kbits/ frame= 99 fps=7.9 q=29.0 size= 890kB time=00:00:03.37 bitrate=2161.8kbits/ frame= 103 fps=7.9 q=29.0 size= 968kB time=00:00:03.50 bitrate=2264.7kbits/ frame= 107 fps=7.8 q=29.0 size= 1053kB time=00:00:03.62 bitrate=2376.7kbits/ frame= 111 fps=7.8 q=29.0 size= 1124kB time=00:00:03.75 bitrate=2450.1kbits/ frame= 115 fps=7.8 q=29.0 size= 1192kB time=00:00:03.90 bitrate=2499.5kbits/ frame= 119 fps=7.8 q=29.0 size= 1251kB time=00:00:04.03 bitrate=2540.7kbits/ frame= 123 fps=7.8 q=29.0 size= 1308kB time=00:00:04.16 bitrate=2573.6kbits/ frame= 127 fps=7.8 q=29.0 size= 1365kB time=00:00:04.29 bitrate=2606.3kbits/ frame= 131 fps=7.7 q=29.0 size= 1432kB time=00:00:04.44 bitrate=2642.3kbits/ frame= 135 fps=7.7 q=29.0 size= 1488kB time=00:00:04.56 bitrate=2667.8kbits/ frame= 139 fps=7.7 q=29.0 size= 1542kB time=00:00:04.69 bitrate=2690.3kbits/ frame= 143 fps=7.7 q=29.0 size= 1595kB time=00:00:04.82 bitrate=2708.7kbits/ frame= 147 fps=7.7 q=29.0 size= 1645kB time=00:00:04.97 bitrate=2709.7kbits/ frame= 151 fps=7.7 q=29.0 size= 1698kB time=00:00:04.97 bitrate=2797.2kbits/ frame= 155 fps=7.7 q=29.0 size= 1756kB time=00:00:04.97 bitrate=2892.4kbits/ frame= 160 fps=7.6 q=29.0 size= 1833kB time=00:00:04.97 bitrate=3019.7kbits/ frame= 165 fps=7.7 q=29.0 size= 1902kB time=00:00:04.97 bitrate=3132.8kbits/ frame= 169 fps=7.7 q=29.0 size= 1954kB time=00:00:04.97 bitrate=3219.1kbits/ frame= 173 fps=7.7 q=29.0 size= 2006kB time=00:00:04.97 bitrate=3303.5kbits/ frame= 178 fps=7.7 q=29.0 size= 2066kB time=00:00:04.97 bitrate=3402.7kbits/ frame= 182 fps=7.7 q=29.0 size= 2121kB time=00:00:04.97 bitrate=3493.2kbits/ frame= 187 fps=7.7 q=29.0 size= 2187kB time=00:00:04.97 bitrate=3601.8kbits/ Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory frame= 191 fps=7.7 q=29.0 size= 2262kB time=00:00:04.97 bitrate=3725.2kbits/ Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory frame= 195 fps=7.6 q=29.0 size= 2344kB time=00:00:04.97 bitrate=3860.9kbits/ Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory ..... Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory frame= 436 fps=7.9 q=29.0 size= 2466kB time=00:00:12.77 bitrate=1580.9kbits/ Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory frame= 440 fps=7.9 q=29.0 size= 2466kB time=00:00:12.91 bitrate=1564.5kbits/ Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory Failed to inject frame into filter network: Cannot allocate memory Error while decoding stream #1:1: Cannot allocate memory frame= 446 fps=8.0 q=29.0 size= 2466kB time=00:00:13.11 bitrate=1540.7kbits/ frame= 450 fps=8.0 q=29.0 size= 2466kB time=00:00:13.24 bitrate=1525.1kbits/ frame= 450 fps=7.7 q=-1.0 Lsize= 5298kB time=00:00:14.91 bitrate=2910.2kbits /s speed=0.255x video:5213kB audio:76kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.194365% [aac @ 0000000001f5bb20] Qavg: 5159.816 [libx264 @ 0000000001cd03e0] frame I:2 Avg QP:20.68 size: 76647 [libx264 @ 0000000001cd03e0] frame P:113 Avg QP:21.48 size: 25608 [libx264 @ 0000000001cd03e0] frame B:335 Avg QP:24.65 size: 6836 [libx264 @ 0000000001cd03e0] consecutive B-frames: 0.7% 0.0% 0.7% 98.7% [libx264 @ 0000000001cd03e0] mb I I16..4: 21.3% 66.8% 11.9% [libx264 @ 0000000001cd03e0] mb P I16..4: 4.0% 5.3% 0.5% P16..4: 45.0% 11.2 % 5.0% 0.0% 0.0% skip:29.1% [libx264 @ 0000000001cd03e0] mb B I16..4: 0.6% 0.6% 0.0% B16..8: 35.6% 2.3 % 0.2% direct: 1.9% skip:58.7% L0:44.8% L1:52.0% BI: 3.2% [libx264 @ 0000000001cd03e0] 8x8 transform intra:54.6% inter:85.5% [libx264 @ 0000000001cd03e0] coded y,uvDC,uvAC intra: 30.3% 42.6% 4.6% inter: 7. 5% 12.1% 0.0% [libx264 @ 0000000001cd03e0] i16 v,h,dc,p: 32% 49% 8% 11% [libx264 @ 0000000001cd03e0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 29% 23% 33% 3% 2% 2% 2% 3% 4% [libx264 @ 0000000001cd03e0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 34% 29% 14% 3% 4% 4% 4% 3% 4% [libx264 @ 0000000001cd03e0] i8c dc,h,v,p: 48% 31% 18% 3% [libx264 @ 0000000001cd03e0] Weighted P-Frames: Y:0.0% UV:0.0% [libx264 @ 0000000001cd03e0] ref P L0: 54.3% 9.2% 25.5% 11.0% [libx264 @ 0000000001cd03e0] ref B L0: 80.4% 15.0% 4.6% [libx264 @ 0000000001cd03e0] ref B L1: 91.3% 8.7% [libx264 @ 0000000001cd03e0] kb/s:2843.59


Sarà necessario visualizzare l'output della console completa per eseguire il debug dell'errore di memoria.
Gyan,

Risposte:


2

Prova con il amixfiltro, che per impostazione predefinita termina con la durata più lunga:

ffmpeg -i v1.mp4 -i v2.mp4 -filter_complex "amix;blend=all_expr='A*0.5+B*0.5'" output.mp4

È inoltre possibile riempire l'audio più corto se si utilizza il comando corrente. Supponiamo che v1 sia il video più breve:

ffmpeg -i v1.mp4 -i v2.mp4 -filter_complex "[0]apad[a];[a][1]amerge=inputs=2,pan=stereo|c0<c0+c1|c1<c2+c3;blend=all_expr='A*0.5+B*0.5'" output.mp4

Grazie! il amixsuggerimento ha risolto il clipping audio ma (ovviamente) non il panning, ma il apadsuggerimento fa tutto ciò di cui ho bisogno. Lo apprezzo molto.
iamchriskelley,
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.