0

I have a bunch of small mp4 files (without audio), and an mp3 audio file. Using the concat protocol, I concatenated them with -shortest flag

ffmpeg -f concat -safe 0 -i "list.txt" -i "../rough_work/output1.mp3" -shortest -c copy "combined.mp4"

ffprobe of sample .mp4 input file without audio

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '5-sec-vid8123.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Bandicut 3.5.0.599 / Cutter / HS
  Duration: 00:00:05.02, start: 0.000000, bitrate: 2346 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 2343 kb/s, 30.09 fps, 60 tbr, 11988 tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]

ffprobe of input mp3 audio file

Input #0, mp3, from 'output1.mp3':
  Metadata:
    encoder         : Lavf58.45.100
  Duration: 00:07:38.21, start: 0.023021, bitrate: 128 kb/s
    Stream #0:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.91

ffprobe of output mp4 file (combined.mp4)

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'combined.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:04:10.46, start: 0.000000, bitrate: 2879 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1 DAR 16:9], 2745 kb/s, 30.03 fps, 59.94 tbr, 11988 tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
      vendor_id       : [0][0][0][0]

After playing combined.mp4, it is working as expected, with no issues. Now I want to add overlays and intro/outro. So I use the following command to add overlays at different timestamps:

ffmpeg -i combined.mp4 -i ../overlay/1280x720-a.png -i ../overlay/1920x1080-a.png -i ../overlay/1280x720-b.png -filter_complex "[0][1]overlay=(W-w)/2:(H-h)/2:enable='between(t,23,27)'[v1]; [v1][2]overlay=(W-w)/2:(H-h)/2:enable='between(t,44,61)'[v2]; [v2][3]overlay=(W-w)/2:(H-h)/2:enable='gt(t,112)'[v3]" -map "[v3]" out.mp4

But out.mp4 (after adding overlays) has some issues

I am using both processes via a bash script whose output is

ffmpeg version 4.3.1-4ubuntu1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10 (Ubuntu 10.2.0-9ubuntu2)
  configuration: --prefix=/usr --extra-version=4ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_6
u --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enab
e-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --
tconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --
openjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsv
le-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora -
ibvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --en
nable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocket
e-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 -
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100


[mov,mp4,m4a,3gp,3g2,mj2 @ 0x560e30f1cec0] Auto-inserting h264_mp4toannexb bitstream filter
Input #0, concat, from 'list.txt':
  Duration: N/A, start: 0.000000, bitrate: 2025 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1
8 tbn, 59.94 tbc
    Metadata:
      handler_name    : VideoHandler
Input #1, mp3, from '../rough_work/output1.mp3':
  Metadata:
    encoder         : Lavf58.45.100
  Duration: 00:07:38.21, start: 0.023021, bitrate: 128 kb/s
    Stream #1:0: Audio: mp3, 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.91
Output #0, mp4, to 'combined.mp4':
  Metadata:
    encoder         : Lavf58.45.100
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1
br, 11988 tbn, 11988 tbc
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1: Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s
    Metadata:
      encoder         : Lavc58.91
Stream mapping:
  Stream #0:0 -> #0:0 (copy)
  Stream #1:0 -> #0:1 (copy)
Press [q] to stop, [?] for help
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da000d000] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0004d80] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0009e80] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0455080] Auto-inserting h264_mp4toannexb bitstream filter
    Last message repeated 7 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0471380] Auto-inserting h264_mp4toannexb bitstream filter
    Last message repeated 5 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0471380] Auto-inserting h264_mp4toannexb bitstream filter5x
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da045f200] Auto-inserting h264_mp4toannexb bitstream filter
    Last message repeated 6 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0480e00] Auto-inserting h264_mp4toannexb bitstream filter
    Last message repeated 6 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da002b740] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da002b700] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0480e00] Auto-inserting h264_mp4toannexb bitstream filter62x
    Last message repeated 15 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0480e00] Auto-inserting h264_mp4toannexb bitstream filter60x
    Last message repeated 17 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0480e00] Auto-inserting h264_mp4toannexb bitstream filter64x
    Last message repeated 16 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0480e00] Auto-inserting h264_mp4toannexb bitstream filter64x
    Last message repeated 1 times
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0450340] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0480e00] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0450340] Auto-inserting h264_mp4toannexb bitstream filter
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x7f2da0480e00] Auto-inserting h264_mp4toannexb bitstream filter
frame=13764 fps=4799 q=-1.0 Lsize=  161200kB time=00:07:38.16 bitrate=2882.3kbits/s speed= 160x
video:153664kB audio:7160kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.233


ffmpeg version 4.3.1-4ubuntu1 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 10 (Ubuntu 10.2.0-9ubuntu2)
  configuration: --prefix=/usr --extra-version=4ubuntu1 --toolchain=hardened --libdir=/usr/lib/x86_6
u --arch=amd64 --enable-gpl --disable-stripping --enable-avresample --disable-filter=resample --enab
e-libass --enable-libbluray --enable-libbs2b --enable-libcaca --enable-libcdio --enable-libcodec2 --
tconfig --enable-libfreetype --enable-libfribidi --enable-libgme --enable-libgsm --enable-libjack --
openjpeg --enable-libopenmpt --enable-libopus --enable-libpulse --enable-librabbitmq --enable-librsv
le-libsnappy --enable-libsoxr --enable-libspeex --enable-libsrt --enable-libssh --enable-libtheora -
ibvorbis --enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx265 --enable-libxml2 --en
nable-lv2 --enable-omx --enable-openal --enable-opencl --enable-opengl --enable-sdl2 --enable-pocket
e-libdrm --enable-libiec61883 --enable-nvenc --enable-chromaprint --enable-frei0r --enable-libx264 -
  libavutil      56. 51.100 / 56. 51.100
  libavcodec     58. 91.100 / 58. 91.100
  libavformat    58. 45.100 / 58. 45.100
  libavdevice    58. 10.100 / 58. 10.100
  libavfilter     7. 85.100 /  7. 85.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  7.100 /  5.  7.100
  libswresample   3.  7.100 /  3.  7.100
  libpostproc    55.  7.100 / 55.  7.100


Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'combined.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:07:38.25, start: 0.000000, bitrate: 2881 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p(tv, bt709), 1920x1080 [SAR 1:1
8 tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: mp3 (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 128 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, png_pipe, from '../overlay/1280x720-a.png':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: png, rgba(pc), 1280x720 [SAR 11811:11811 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #2, png_pipe, from '../overlay/1920x1080-a.png':
  Duration: N/A, bitrate: N/A
    Stream #2:0: Video: png, rgba(pc), 1920x1080 [SAR 11811:11811 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Input #3, png_pipe, from '../overlay/1280x720-b.png':
  Duration: N/A, bitrate: N/A
    Stream #3:0: Video: png, rgba(pc), 1280x720 [SAR 11811:11811 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (h264) -> overlay:main
  Stream #1:0 (png) -> overlay:overlay
  Stream #2:0 (png) -> overlay:overlay
  Stream #3:0 (png) -> overlay:overlay
  overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x55c7f67c4b80] using SAR=1/1
[libx264 @ 0x55c7f67c4b80] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2 AVX
[libx264 @ 0x55c7f67c4b80] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x55c7f67c4b80] 264 - core 160 r3011 cde9a93 - H.264/MPEG-4 AVC codec - Copyleft 2003-202
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_r
zone=21,11 fast_pskip=1 chroma_qp_offset=-2 threads=3 lookahead_threads=1 sliced_threads=0 nr=0 deci
ntra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=2 keyint=250 k
head=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
    encoder         : Lavf58.45.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q
    Metadata:
      encoder         : Lavc58.91.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
[h264 @ 0x55c7f67f4280] illegal short term buffer state detectedate=2664.3kbits/s dup=14 drop=6 spee
[h264 @ 0x55c7f6839080] mmco: unref short failure
[h264 @ 0x55c7f67c9500] mmco: unref short failure0:03:04.08 bitrate=2984.8kbits/s dup=14 drop=10 spe
[h264 @ 0x55c7f6839080] illegal short term buffer state detectedate=3093.7kbits/s dup=44 drop=15 spe
[h264 @ 0x55c7f67c9500] mmco: unref short failure
[h264 @ 0x55c7f67f4280] mmco: unref short failure0:07:14.43 bitrate=3186.0kbits/s dup=44 drop=18 spe
frame=13734 fps= 12 q=-1.0 Lsize=  185395kB time=00:07:38.15 bitrate=3314.9kbits/s dup=54 drop=18 sp
video:185237kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.085523
[libx264 @ 0x55c7f67c4b80] frame I:225   Avg QP:18.11  size:129889
[libx264 @ 0x55c7f67c4b80] frame P:3926  Avg QP:21.67  size: 25998
[libx264 @ 0x55c7f67c4b80] frame B:9583  Avg QP:24.90  size:  6093
[libx264 @ 0x55c7f67c4b80] consecutive B-frames:  2.7%  7.1% 17.5% 72.8%
[libx264 @ 0x55c7f67c4b80] mb I  I16..4: 21.2% 56.6% 22.3%
[libx264 @ 0x55c7f67c4b80] mb P  I16..4:  4.6%  8.1%  0.6%  P16..4: 37.5% 10.5%  5.2%  0.0%  0.0%
[libx264 @ 0x55c7f67c4b80] mb B  I16..4:  0.3%  0.4%  0.1%  B16..8: 36.9%  2.5%  0.4%  direct: 0.7%
[libx264 @ 0x55c7f67c4b80] 8x8 transform intra:59.1% inter:75.7%
[libx264 @ 0x55c7f67c4b80] coded y,uvDC,uvAC intra: 29.4% 37.0% 7.7% inter: 5.5% 5.2% 0.1%
[libx264 @ 0x55c7f67c4b80] i16 v,h,dc,p: 27% 37% 12% 24%
[libx264 @ 0x55c7f67c4b80] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 23% 36%  2%  2%  2%  3%  2%  4%
[libx264 @ 0x55c7f67c4b80] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 30% 29% 12%  4%  5%  4%  6%  4%  6%
[libx264 @ 0x55c7f67c4b80] i8c dc,h,v,p: 56% 25% 16%  4%
[libx264 @ 0x55c7f67c4b80] Weighted P-Frames: Y:2.7% UV:1.0%
[libx264 @ 0x55c7f67c4b80] ref P L0: 65.3% 15.2% 15.0%  4.4%  0.1%
[libx264 @ 0x55c7f67c4b80] ref B L0: 89.8%  8.7%  1.5%
[libx264 @ 0x55c7f67c4b80] ref B L1: 97.9%  2.1%
[libx264 @ 0x55c7f67c4b80] kb/s:3311.35

there is no audio in out.mp4 (output) while there was in combined.mp4 (input) so I cannot transmit it over youtube. The same happens when I add intro/outro to combined.mp4

please help me with this, I am new to FFmpeg, I tried searching docs and previous similar questions but I am not able to solve this issue.

ffprobe of out.mp4

Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'out.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf58.45.100
  Duration: 00:07:38.26, start: 0.000000, bitrate: 3314 kb/s
    Stream #0:0(und): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], 3311 kb/s, 29.97 fps, 29.97 tbr, 11988 tbn, 59.94 tbc (default)
    Metadata:
      handler_name    : VideoHandler
      vendor_id       : [0][0][0][0]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.