[FFmpeg-user] Mix a video with an audio file

Paul B Mahol onemda at gmail.com
Sun Jan 19 22:01:38 EET 2020


On 1/19/20, Michael Koch <astroelectronic at t-online.de> wrote:
> Hello,
>
> I've just found a problem that can be reproduced as follows:
>
> Step 1: Make a 6 seconds test video with 1kHz tone. The file is ok when
> played.
>
> ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y video.mp4
>
>
> Step 2: Make a 10 seconds audio file with silence and a short 3kHz tone
> at t=3s. The file is ok when played.
>
> ffmpeg -f lavfi -i "sine=3000:duration=0.1" -af adelay=3000,apad -t 10
> -y audio.wav
>
>
> Step 3: Combine both files into one video, and the audio sources shall
> be mixed:
>
> ffmpeg -i video.mp4 -i audio.wav -filter_complex
> "[0:a][1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
>
> The output video has the correct length 6s, but I don't understand why
> the 1kHz tone disappears after 4s and the last 2s are silence.
>
> The console output is below.

Can not reproduce using nut container.

> Michael
>
>
>
> F:\Test_Audio>c:\ffmpeg\ffmpeg -i video.mp4 -i audio.wav -filter_complex
> "[0:a][
> 1:a]amix=weights='1.0 1.0'" -shortest -y out.mp4
> ffmpeg version git-2020-01-15-0dc0837 Copyright (c) 2000-2020 the FFmpeg
> develop
> ers
>    built with gcc 9.2.1 (GCC) 20200111
>    configuration: --enable-gpl --enable-version3 --enable-sdl2
> --enable-fontconfi
> g --enable-gnutls --enable-iconv --enable-libass --enable-libdav1d
> --enable-libb
> luray --enable-libfreetype --enable-libmp3lame
> --enable-libopencore-amrnb --enab
> le-libopencore-amrwb --enable-libopenjpeg --enable-libopus
> --enable-libshine --e
> nable-libsnappy --enable-libsoxr --enable-libtheora --enable-libtwolame
> --enable
> -libvpx --enable-libwavpack --enable-libwebp --enable-libx264
> --enable-libx265 -
> -enable-libxml2 --enable-libzimg --enable-lzma --enable-zlib
> --enable-gmp --enab
> le-libvidstab --enable-libvorbis --enable-libvo-amrwbenc
> --enable-libmysofa --en
> able-libspeex --enable-libxvid --enable-libaom --enable-libmfx
> --enable-ffnvcode
> c --enable-cuvid --enable-d3d11va --enable-nvenc --enable-nvdec
> --enable-dxva2 -
> -enable-avisynth --enable-libopenmpt --enable-amf
>    libavutil      56. 38.100 / 56. 38.100
>    libavcodec     58. 65.103 / 58. 65.103
>    libavformat    58. 35.102 / 58. 35.102
>    libavdevice    58.  9.103 / 58.  9.103
>    libavfilter     7. 71.100 /  7. 71.100
>    libswscale      5.  6.100 /  5.  6.100
>    libswresample   3.  6.100 /  3.  6.100
>    libpostproc    55.  6.100 / 55.  6.100
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
>    Metadata:
>      major_brand     : isom
>      minor_version   : 512
>      compatible_brands: isomiso2avc1mp41
>      encoder         : Lavf58.35.102
>    Duration: 00:00:06.02, start: 0.000000, bitrate: 938 kb/s
>      Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> 640x480 [
> SAR 1:1 DAR 4:3], 864 kb/s, 25 fps, 25 tbr, 12800 tbn, 50 tbc (default)
>      Metadata:
>        handler_name    : VideoHandler
>      Stream #0:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz,
> mono, fltp,
>   68 kb/s (default)
>      Metadata:
>        handler_name    : SoundHandler
> Guessed Channel Layout for Input Stream #1.0 : mono
> Input #1, wav, from 'audio.wav':
>    Metadata:
>      encoder         : Lavf58.35.102
>    Duration: 00:00:10.00, bitrate: 705 kb/s
>      Stream #1:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 44100 Hz,
> mono, s16,
> 705 kb/s
> Stream mapping:
>    Stream #0:1 (aac) -> amix:input0 (graph 0)
>    Stream #1:0 (pcm_s16le) -> amix:input1 (graph 0)
>    amix (graph 0) -> Stream #0:0 (aac)
>    Stream #0:0 -> #0:1 (h264 (native) -> h264 (libx264))
> Press [q] to stop, [?] for help
> [libx264 @ 00000000029d7540] using SAR=1/1
> [libx264 @ 00000000029d7540] using cpu capabilities: MMX2 SSE2Fast SSSE3
> SSE4.2
> AVX FMA3 BMI2 AVX2
> [libx264 @ 00000000029d7540] profile High, level 3.0, 4:2:0, 8-bit
> [libx264 @ 00000000029d7540] 264 - core 159 - H.264/MPEG-4 AVC codec -
> Copyleft
> 2003-2019 - 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_rang
> e=16 chroma_me=1 trellis=1 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1
> chroma_qp_
> offset=-2 threads=6 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1
> interla
> ced=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 qpma
> x=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
>      encoder         : Lavf58.35.102
>      Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono,
> fltp, 69 k
> b/s (default)
>      Metadata:
>        encoder         : Lavc58.65.103 aac
>      Stream #0:1(und): Video: h264 (libx264) (avc1 / 0x31637661),
> yuv420p, 640x48
> 0 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
>      Metadata:
>        handler_name    : VideoHandler
>        encoder         : Lavc58.65.103 libx264
>      Side data:
>        cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
> frame=  111 fps=0.0 q=28.0 size=     256kB time=00:00:02.36 bitrate=
> 885.6kbits/
> frame=  150 fps=141 q=-1.0 Lsize=     635kB time=00:00:06.01 bitrate=
> 864.7kbits
> /s speed=5.66x
> video:612kB audio:17kB subtitle:0kB other streams:0kB global headers:0kB
> muxing
> overhead: 0.982628%
> [aac @ 00000000029dbb40] Qavg: 62202.113
> [libx264 @ 00000000029d7540] frame I:1     Avg QP:18.28  size:  9171
> [libx264 @ 00000000029d7540] frame P:47    Avg QP:25.28  size:  5109
> [libx264 @ 00000000029d7540] frame B:102   Avg QP:29.85  size:  3690
> [libx264 @ 00000000029d7540] consecutive B-frames:  2.0% 13.3% 26.0% 58.7%
> [libx264 @ 00000000029d7540] mb I  I16..4: 45.2% 42.3% 12.5%
> [libx264 @ 00000000029d7540] mb P  I16..4:  1.5%  5.5%  0.8% P16..4:
> 11.1%  5.0
> %  2.8%  0.0%  0.0%    skip:73.3%
> [libx264 @ 00000000029d7540] mb B  I16..4:  0.2%  0.1%  0.5% B16..8:
> 14.1%  3.7
> %  0.9%  direct: 1.7%  skip:78.6%  L0:49.5% L1:44.3% BI: 6.2%
> [libx264 @ 00000000029d7540] 8x8 transform intra:56.4% inter:25.6%
> [libx264 @ 00000000029d7540] coded y,uvDC,uvAC intra: 19.1% 27.7% 26.1%
> inter: 4
> .0% 9.1% 7.5%
> [libx264 @ 00000000029d7540] i16 v,h,dc,p: 71% 19%  8%  1%
> [libx264 @ 00000000029d7540] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 12% 75%
> 0%  0%
>   0%  0%  0%  0%
> [libx264 @ 00000000029d7540] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 22% 33%
> 7%  3%
>   4%  4%  6%  4%
> [libx264 @ 00000000029d7540] i8c dc,h,v,p: 71% 11% 17%  2%
> [libx264 @ 00000000029d7540] Weighted P-Frames: Y:0.0% UV:0.0%
> [libx264 @ 00000000029d7540] ref P L0: 56.9%  7.7% 22.6% 12.9%
> [libx264 @ 00000000029d7540] ref B L0: 74.2% 21.4%  4.4%
> [libx264 @ 00000000029d7540] ref B L1: 94.6%  5.4%
> [libx264 @ 00000000029d7540] kb/s:834.26
> _______________________________________________
> ffmpeg-user mailing list
> ffmpeg-user at ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-user
>
> To unsubscribe, visit link above, or email
> ffmpeg-user-request at ffmpeg.org with subject "unsubscribe".


More information about the ffmpeg-user mailing list