[FFmpeg-user] Overlay two videos: Black frames

Jonathan Girven jonathan.girven at trickbook.com
Wed Jan 10 18:49:49 EET 2018


I am trying to perform a complex filter to merge two videos one after the
other. The output video appears to have black frames in it where the input
videos do not (at the end of the first and second video). The FFmpeg command
and output is:

ffmpeg -y -i input1.mp4 -i input2.mp4 -f lavfi -i
color=black:s=1920x1080:d=6.0 -filter_complex
"[1:v]setpts=expr=PTS-STARTPTS+3.0/TB[v1];
[2:v][0:v]overlay=eof_action=pass[over1];
[over1][v1]overlay=eof_action=pass[over2]" -vcodec libx264 -map [over2]
output.mp4

ffmpeg version 3.4.1 Copyright (c) 2000-2017 the FFmpeg developers
  built with gcc 6.2.1 (Alpine 6.2.1) 20160822
  configuration: --disable-debug --disable-doc --disable-ffplay
--enable-shared --enable-avresample --enable-libopencore-amrnb
--enable-libopencore-amrwb --enable-gpl --enable-libass --enable-libfreetype
--enable-libvidstab --enable-libmp3lame --enable-libopenjpeg
--enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx
--enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree
--enable-openssl --enable-libfdk_aac --enable-postproc --enable-small
--enable-version3 --extra-cflags=-I/opt/ffmpeg/include
--extra-ldflags=-L/opt/ffmpeg/lib --extra-libs=-ldl --prefix=/opt/ffmpeg
  libavutil      55. 78.100 / 55. 78.100
  libavcodec     57.107.100 / 57.107.100
  libavformat    57. 83.100 / 57. 83.100
  libavdevice    57. 10.100 / 57. 10.100
  libavfilter     6.107.100 /  6.107.100
  libavresample   3.  7.  0 /  3.  7.  0
  libswscale      4.  8.100 /  4.  8.100
  libswresample   2.  9.100 /  2.  9.100
  libpostproc    54.  7.100 / 54.  7.100
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.61.100
  Duration: 00:00:03.09, start: 0.000000, bitrate: 302 kb/s
    Stream #0:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080
[SAR 1:1 DAR 16:9], 269 kb/s, 2 fps, 2 tbr, 16384 tbn, 4 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #0:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
fltp, 35 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #1, mov,mp4,m4a,3gp,3g2,mj2, from 'input2.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.61.100
  Duration: 00:00:03.09, start: 0.000000, bitrate: 466 kb/s
    Stream #1:0(und): Video: h264 (avc1 / 0x31637661), yuv420p, 1920x1080
[SAR 1:1 DAR 16:9], 438 kb/s, 2 fps, 2 tbr, 16384 tbn, 4 tbc (default)
    Metadata:
      handler_name    : VideoHandler
    Stream #1:1(und): Audio: aac (mp4a / 0x6134706D), 44100 Hz, stereo,
fltp, 35 kb/s (default)
    Metadata:
      handler_name    : SoundHandler
Input #2, lavfi, from 'color=black:s=1920x1080:d=6.0':
  Duration: N/A, start: 0.000000, bitrate: N/A
    Stream #2:0: Video: rawvideo (I420 / 0x30323449), yuv420p, 1920x1080
[SAR 1:1 DAR 16:9], 25 tbr, 25 tbn, 25 tbc
Stream mapping:
  Stream #0:0 (h264) -> overlay:overlay
  Stream #1:0 (h264) -> setpts
  Stream #2:0 (rawvideo) -> overlay:main
  overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x55e7ab444da0] using SAR=1/1
[libx264 @ 0x55e7ab444da0] using cpu capabilities: MMX2 SSE2Fast SSSE3
SSE4.2 AVX FMA3 AVX2 LZCNT BMI2
[libx264 @ 0x55e7ab444da0] profile High, level 4.0
[libx264 @ 0x55e7ab444da0] 264 - core 148 - H.264/MPEG-4 AVC codec -
Copyleft 2003-2016 - 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=12 lookahead_threads=2
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=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 'output.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.83.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p,
1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 25 fps, 12800 tbn, 25 tbc (default)
    Metadata:
      encoder         : Lavc57.107.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: -1
[Parsed_color_0 @ 0x55e7ab540820] EOF timestamp not reliablebitrate=
708.6kbits/s speed=1.46x    
frame=  150 fps= 60 q=-1.0 Lsize=     410kB time=00:00:05.88 bitrate=
571.0kbits/s speed=2.35x    
video:407kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB
muxing overhead: 0.637398%
[libx264 @ 0x55e7ab444da0] frame I:2     Avg QP:13.72  size:190245
[libx264 @ 0x55e7ab444da0] frame P:38    Avg QP:15.10  size:   572
[libx264 @ 0x55e7ab444da0] frame B:110   Avg QP:14.82  size:   128
[libx264 @ 0x55e7ab444da0] consecutive B-frames:  1.3%  2.7%  0.0% 96.0%
[libx264 @ 0x55e7ab444da0] mb I  I16..4: 21.7% 44.7% 33.5%
[libx264 @ 0x55e7ab444da0] mb P  I16..4:  0.0%  0.0%  0.0%  P16..4:  1.7% 
0.1%  0.2%  0.0%  0.0%    skip:97.9%
[libx264 @ 0x55e7ab444da0] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.9% 
0.0%  0.0%  direct: 0.0%  skip:99.1%  L0:21.8% L1:78.2% BI: 0.0%
[libx264 @ 0x55e7ab444da0] 8x8 transform intra:44.6% inter:67.8%
[libx264 @ 0x55e7ab444da0] coded y,uvDC,uvAC intra: 66.7% 53.0% 31.6% inter:
0.1% 0.3% 0.0%
[libx264 @ 0x55e7ab444da0] i16 v,h,dc,p: 36% 10% 29% 25%
[libx264 @ 0x55e7ab444da0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 11% 40%  3% 
2%  3%  2%  7%  5%
[libx264 @ 0x55e7ab444da0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 14% 15%  7% 
5%  6%  4% 13%  6%
[libx264 @ 0x55e7ab444da0] i8c dc,h,v,p: 57% 19% 17%  8%
[libx264 @ 0x55e7ab444da0] Weighted P-Frames: Y:5.3% UV:5.3%
[libx264 @ 0x55e7ab444da0] ref P L0: 93.0%  0.8%  5.4%  0.8%
[libx264 @ 0x55e7ab444da0] ref B L0: 57.8% 42.1%  0.1%
[libx264 @ 0x55e7ab444da0] ref B L1: 93.5%  6.5%
[libx264 @ 0x55e7ab444da0] kb/s:555.11

I understand there are easier ways to concatenate two videos, but this is a
simplification of a more complicated command.

The two input files are here:

input1.mp4 <http://www.ffmpeg-archive.org/file/t377720/input1.mp4>  
input2.mp4 <http://www.ffmpeg-archive.org/file/t377720/input2.mp4>  

I made the input files using Android MediaCodec, so I suspect there may be
some issue with the timings of frames or something. FFmpeg does not output
any warnings though. Can anyone help me find out why these black frames are
appearing?




--
Sent from: http://www.ffmpeg-archive.org/


More information about the ffmpeg-user mailing list