[FFmpeg-user] audio is too short

Michael Koch astroelectronic at t-online.de
Wed Feb 26 17:48:15 EET 2020


Hi,

I'd like to know if someone can reproduce this problem:

Make a 6s video with audio:
ffmpeg -f lavfi -i testsrc2=size=vga -f lavfi -i sine=1000 -t 6 -y video.mp4
The video plays correctly and has 6s of audio.

Now mix the audio channels from two of these input videos:
ffmpeg -i video.mp4 -i video.mp4 -lavfi "[0:a][1:a]amix=weights='1.0 
0.1'" -y out.mp4

You can hear that the audio from the first input ends too early at 4s, 
and the audio from the second input has the correct length 6s.
Tested with FFplay and VLC.

Known workaround: add -c:v mpeg4

This is ticket 8489, but so far nobody did have a look at it.

Michael



C:\Users\mKoch\Desktop>c:\ffmpeg\ffmpeg -f lavfi -i testsrc2=size=vga -f 
lavfi -
i sine=1000 -t 6 -y video.mp4
ffmpeg version git-2020-02-25-36451f9 Copyright (c) 2000-2020 the FFmpeg 
develop
ers
   built with gcc 9.2.1 (GCC) 20200122
   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-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc 
--enable-nvd
ec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
   libavutil      56. 42.100 / 56. 42.100
   libavcodec     58. 73.102 / 58. 73.102
   libavformat    58. 39.101 / 58. 39.101
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 77.100 /  7. 77.100
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
Input #0, lavfi, from 'testsrc2=size=vga':
   Duration: N/A, start: 0.000000, bitrate: N/A
     Stream #0:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 640x480 
[SAR 1:1
DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Input #1, lavfi, from 'sine=1000':
   Duration: N/A, start: 0.000000, bitrate: 705 kb/s
     Stream #1:0: Audio: pcm_s16le, 44100 Hz, mono, s16, 705 kb/s
Stream mapping:
   Stream #0:0 -> #0:0 (rawvideo (native) -> h264 (libx264))
   Stream #1:0 -> #0:1 (pcm_s16le (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 00000000001bee80] using SAR=1/1
[libx264 @ 00000000001bee80] using cpu capabilities: MMX2 SSE2Fast SSSE3 
SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 @ 00000000001bee80] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 00000000001bee80] 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 'video.mp4':
   Metadata:
     encoder         : Lavf58.39.101
     Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), 
yuv420p(progressive)
, 640x480 [SAR 1:1 DAR 4:3], q=-1--1, 25 fps, 12800 tbn, 25 tbc
     Metadata:
       encoder         : Lavc58.73.102 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
     Stream #0:1: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, 
fltp, 69 k
b/s
     Metadata:
       encoder         : Lavc58.73.102 aac
frame=  103 fps=0.0 q=28.0 size=       0kB time=00:00:02.02 bitrate=   
0.2kbits/
frame=  150 fps=128 q=-1.0 Lsize=     690kB time=00:00:06.01 bitrate= 
940.0kbits
/s speed=5.14x
video:633kB audio:51kB subtitle:0kB other streams:0kB global headers:0kB 
muxing
overhead: 0.899108%
[libx264 @ 00000000001bee80] frame I:1     Avg QP:21.21  size:  9168
[libx264 @ 00000000001bee80] frame P:46    Avg QP:26.76  size:  5209
[libx264 @ 00000000001bee80] frame B:103   Avg QP:30.60  size:  3875
[libx264 @ 00000000001bee80] consecutive B-frames:  1.3% 10.7% 32.0% 56.0%
[libx264 @ 00000000001bee80] mb I  I16..4: 25.0% 62.2% 12.8%
[libx264 @ 00000000001bee80] mb P  I16..4:  1.5%  6.0%  1.0% P16..4:  
9.3%  5.3
%  2.9%  0.0%  0.0%    skip:74.1%
[libx264 @ 00000000001bee80] mb B  I16..4:  0.2%  0.4%  0.5% B16..8: 
13.8%  4.2
%  1.0%  direct: 1.7%  skip:78.3%  L0:50.3% L1:42.7% BI: 7.0%
[libx264 @ 00000000001bee80] 8x8 transform intra:63.2% inter:22.1%
[libx264 @ 00000000001bee80] coded y,uvDC,uvAC intra: 16.1% 23.3% 22.4% 
inter: 4
.2% 8.7% 7.4%
[libx264 @ 00000000001bee80] i16 v,h,dc,p: 70% 23%  6%  1%
[libx264 @ 00000000001bee80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 15% 73%  
0%  0%
  0%  0%  0%  0%
[libx264 @ 00000000001bee80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 21% 22% 31%  
6%  3%
  4%  3%  5%  3%
[libx264 @ 00000000001bee80] i8c dc,h,v,p: 69% 11% 19%  1%
[libx264 @ 00000000001bee80] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000000001bee80] ref P L0: 55.3%  6.9% 23.3% 14.5%
[libx264 @ 00000000001bee80] ref B L0: 71.5% 23.5%  5.0%
[libx264 @ 00000000001bee80] ref B L1: 93.0%  7.0%
[libx264 @ 00000000001bee80] kb/s:863.86
[aac @ 00000000032a88c0] Qavg: 19623.219

C:\Users\mKoch\Desktop>c:\ffmpeg\ffmpeg -i video.mp4 -i video.mp4 -lavfi 
"[0:a][
1:a]amix=weights='1.0 0.1'" -y out.mp4
ffmpeg version git-2020-02-25-36451f9 Copyright (c) 2000-2020 the FFmpeg 
develop
ers
   built with gcc 9.2.1 (GCC) 20200122
   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-cuda-llvm --enable-cuvid --enable-d3d11va --enable-nvenc 
--enable-nvd
ec --enable-dxva2 --enable-avisynth --enable-libopenmpt --enable-amf
   libavutil      56. 42.100 / 56. 42.100
   libavcodec     58. 73.102 / 58. 73.102
   libavformat    58. 39.101 / 58. 39.101
   libavdevice    58.  9.103 / 58.  9.103
   libavfilter     7. 77.100 /  7. 77.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.39.101
   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
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'video.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf58.39.101
   Duration: 00:00:06.02, start: 0.000000, bitrate: 938 kb/s
     Stream #1: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 #1:1(und): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, 
mono, fltp,
  68 kb/s (default)
     Metadata:
       handler_name    : SoundHandler
Stream mapping:
   Stream #0:1 (aac) -> amix:input0 (graph 0)
   Stream #1:1 (aac) -> 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 @ 00000000004de280] using SAR=1/1
[libx264 @ 00000000004de280] using cpu capabilities: MMX2 SSE2Fast SSSE3 
SSE4.2
AVX FMA3 BMI2 AVX2
[libx264 @ 00000000004de280] profile High, level 3.0, 4:2:0, 8-bit
[libx264 @ 00000000004de280] 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.39.101
     Stream #0:0: Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, mono, 
fltp, 69 k
b/s (default)
     Metadata:
       encoder         : Lavc58.73.102 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.73.102 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=   95 fps=0.0 q=28.0 size=       0kB time=00:00:01.69 bitrate=   
0.2kbits/
frame=  150 fps=130 q=-1.0 Lsize=     661kB time=00:00:06.01 bitrate= 
900.9kbits
/s speed=5.21x
video:612kB audio:43kB subtitle:0kB other streams:0kB global headers:0kB 
muxing
overhead: 0.942758%
[aac @ 0000000002990a40] Qavg: 25713.752
[libx264 @ 00000000004de280] frame I:1     Avg QP:18.28  size:  9171
[libx264 @ 00000000004de280] frame P:47    Avg QP:25.28  size:  5109
[libx264 @ 00000000004de280] frame B:102   Avg QP:29.85  size:  3690
[libx264 @ 00000000004de280] consecutive B-frames:  2.0% 13.3% 26.0% 58.7%
[libx264 @ 00000000004de280] mb I  I16..4: 45.2% 42.3% 12.5%
[libx264 @ 00000000004de280] 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 @ 00000000004de280] 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 @ 00000000004de280] 8x8 transform intra:56.4% inter:25.6%
[libx264 @ 00000000004de280] coded y,uvDC,uvAC intra: 19.1% 27.7% 26.1% 
inter: 4
.0% 9.1% 7.5%
[libx264 @ 00000000004de280] i16 v,h,dc,p: 71% 19%  8%  1%
[libx264 @ 00000000004de280] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 12% 12% 75%  
0%  0%
  0%  0%  0%  0%
[libx264 @ 00000000004de280] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 18% 22% 33%  
7%  3%
  4%  4%  6%  4%
[libx264 @ 00000000004de280] i8c dc,h,v,p: 71% 11% 17%  2%
[libx264 @ 00000000004de280] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 00000000004de280] ref P L0: 56.9%  7.7% 22.6% 12.9%
[libx264 @ 00000000004de280] ref B L0: 74.2% 21.4%  4.4%
[libx264 @ 00000000004de280] ref B L1: 94.6%  5.4%
[libx264 @ 00000000004de280] kb/s:834.26


More information about the ffmpeg-user mailing list