[FFmpeg-user] FFMPEG Images & Audio to Video

Vivek Jain vivek.jain at mindtickle.com
Fri Sep 22 09:43:44 EEST 2017


Hello,

Humble greetings! I have been using ffmpeg to create video from an audio
and set of images (as per command below). Lately I have been noticing
ffmpeg's video output is lengthier than actual length. The produced video
has an extra padding in the end with no audio. Could someone please advise
how can the extra padding in the end be removed?

*Please note that audio's length and combined images duration length is
exactly the same.*

*Command:*

ffmpeg -safe 0 -f concat -i /tmp/911110340433636652_config.txt -i
/tmp/911110340433636652_audio.mp3 -y -vb 8M -vcodec libx264 -pix_fmt
yuv420p -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2'
/tmp/911110340433636652_mashupVideo.mp4

In the example attached, below are the media lengths:

Audio length = 00:10:54.39

Combined Images length = 00:10:54.36

Output Video length = 00:14:18.12 *(which is 3 minutes 24 seconds extra)*

*Output Attached!*
Appreciate much for your help!
-- 
Thanks,
Vivek
-------------- next part --------------
####################################
FFMPEG Command Used to create video
####################################

ubuntu at ffmpeg-workers:~$ ffmpeg -safe 0 -f concat -i /tmp/911110340433636652_config.txt -i /tmp/911110340433636652_audio.mp3 -y -vb 8M -vcodec libx264 -pix_fmt yuv420p -vf 'scale=trunc(iw/2)*2:trunc(ih/2)*2' /tmp/911110340433636652_mashupVideo.mp4
ffmpeg version git-2017-01-22-f1214ad Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
  libavutil      55. 44.100 / 55. 44.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 63.100 / 57. 63.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 69.100 /  6. 69.100
  libavresample   3.  2.  0 /  3.  2.  0
  libswscale      4.  3.101 /  4.  3.101
  libswresample   2.  4.100 /  2.  4.100
  libpostproc    54.  2.100 / 54.  2.100
Input #0, concat, from '/tmp/911110340433636652_config.txt':
  Duration: 00:10:54.36, start: 0.000000, bitrate: 0 kb/s
    Stream #0:0: Video: png, rgb24(pc), 720x540 [SAR 72:72 DAR 4:3], 25 tbr, 25 tbn, 25 tbc
Input #1, mp3, from '/tmp/911110340433636652_audio.mp3':
  Metadata:
    creationdate    : Thu Sep 15 11:24:10
    description     : Recorded using WebcamRecording example.
    encoder         : Lavf57.25.100
  Duration: 00:10:54.39, start: 0.025057, bitrate: 128 kb/s
    Stream #1:0: Audio: mp3, 44100 Hz, stereo, s16p, 128 kb/s
    Metadata:
      encoder         : Lavc57.24
[libx264 @ 0x24a77a0] using SAR=1/1
[libx264 @ 0x24a77a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x24a77a0] profile High, level 3.1
[libx264 @ 0x24a77a0] 264 - core 148 r2643 5c65704 - H.264/MPEG-4 AVC codec - Copyleft 2003-2015 - 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=6 lookahead_threads=1 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=abr mbtree=1 bitrate=8000 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, mp4, to '/tmp/911110340433636652_mashupVideo.mp4':
  Metadata:
    encoder         : Lavf57.63.100
    Stream #0:0: Video: h264 (libx264) ([33][0][0][0] / 0x0021), yuv420p, 720x540 [SAR 1:1 DAR 4:3], q=-1--1, 8000 kb/s, 25 fps, 12800 tbn, 25 tbc
    Metadata:
      encoder         : Lavc57.75.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/8000000 buffer size: 0 vbv_delay: -1
    Stream #0:1: Audio: aac (LC) ([64][0][0][0] / 0x0040), 44100 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc57.75.100 aac
Stream mapping:
  Stream #0:0 -> #0:0 (png (native) -> h264 (libx264))
  Stream #1:0 -> #0:1 (mp3 (native) -> aac (native))
Press [q] to stop, [?] for help
More than 1000 frames duplicated     58kB time=00:00:04.08 bitrate= 115.9kbits/s dup=153 drop=0 speed=8.14x    
More than 10000 frames duplicated  4799kB time=00:03:52.44 bitrate= 169.1kbits/s dup=5861 drop=0 speed=10.5x    
frame=21453 fps=276 q=-1.0 Lsize=   18179kB time=00:14:18.00 bitrate= 173.6kbits/s dup=26695 drop=0 speed=11.1x    
video:7435kB audio:10369kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 2.107383%
[libx264 @ 0x24a77a0] frame I:87    Avg QP: 0.03  size: 81089
[libx264 @ 0x24a77a0] frame P:5403  Avg QP: 0.08  size:    33
[libx264 @ 0x24a77a0] frame B:15963 Avg QP: 4.34  size:    24
[libx264 @ 0x24a77a0] consecutive B-frames:  0.8%  0.0%  0.0% 99.2%
[libx264 @ 0x24a77a0] mb I  I16..4: 73.9%  0.1% 26.0%
[libx264 @ 0x24a77a0] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  0.0%  0.0%  0.0%  0.0%  0.0%    skip:100.0%
[libx264 @ 0x24a77a0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.0%  0.0%  0.0%  direct: 0.0%  skip:100.0%  L0: 0.0% L1:100.0% BI: 0.0%
[libx264 @ 0x24a77a0] final ratefactor: -46.04
[libx264 @ 0x24a77a0] 8x8 transform intra:0.1% inter:18.0%
[libx264 @ 0x24a77a0] coded y,uvDC,uvAC intra: 18.3% 27.5% 27.4% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x24a77a0] i16 v,h,dc,p: 85% 15%  0%  0%
[libx264 @ 0x24a77a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu:  8%  8% 62% 11%  0%  3%  5%  0%  3%
[libx264 @ 0x24a77a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 53% 15%  9%  2%  4%  5%  4%  4%  4%
[libx264 @ 0x24a77a0] i8c dc,h,v,p: 73% 16%  8%  2%
[libx264 @ 0x24a77a0] Weighted P-Frames: Y:0.0% UV:0.0%
[libx264 @ 0x24a77a0] ref P L0: 99.8%  0.0%  0.0%  0.2%
[libx264 @ 0x24a77a0] kb/s:70.97
[aac @ 0x24a8200] Qavg: 719.810



####################################
Output Video Length:
####################################

ubuntu at ffmpeg-workers:~$ ffmpeg -i /tmp/911110340433636652_mashupVideo.mp4
ffmpeg version git-2017-01-22-f1214ad Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 4.8 (Ubuntu 4.8.4-2ubuntu1~14.04.3)
  configuration: --extra-libs=-ldl --prefix=/opt/ffmpeg --mandir=/usr/share/man --enable-avresample --disable-debug --enable-nonfree --enable-gpl --enable-version3 --enable-libopencore-amrnb --enable-libopencore-amrwb --disable-decoder=amrnb --disable-decoder=amrwb --enable-libpulse --enable-libfreetype --enable-gnutls --enable-libx264 --enable-libx265 --enable-libfdk-aac --enable-libvorbis --enable-libmp3lame --enable-libopus --enable-libvpx --enable-libspeex --enable-libass --enable-avisynth --enable-libsoxr --enable-libxvid --enable-libvidstab --enable-libwavpack --enable-nvenc
  libavutil      55. 44.100 / 55. 44.100
  libavcodec     57. 75.100 / 57. 75.100
  libavformat    57. 63.100 / 57. 63.100
  libavdevice    57.  2.100 / 57.  2.100
  libavfilter     6. 69.100 /  6. 69.100
  libavresample   3.  2.  0 /  3.  2.  0
  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 '/tmp/911110340433636652_mashupVideo.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.63.100
  Duration: 00:14:18.12, start: 0.000000, bitrate: 173 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 720x540 [SAR 1:1 DAR 4:3], 70 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, stereo, fltp, 129 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
At least one output file must be specified


More information about the ffmpeg-user mailing list