[FFmpeg-user] gif overlay miscalculating x and y, extra frame flash

S Andreason sandreas41 at gmail.com
Mon Feb 10 00:51:45 EET 2020


Hi,
I continued building and rendering after asking some questions last 
week. After 6 days x10 hours per day of 
(render,test,measure,edit,repeat) I finally was able to publish my 
video. In doing so I made it easy to duplicate the bugs I have been seeing.

I have put the 7 files together in one 56Mb package for you to download at
https://www.seahorsecorral.org/videos/tests/ffmpeg-test-gif.zip

The issue is with -i gif and 
overlay=x=(calculations):y=(calculations):between
1. between calculates n differently than the 30fps video,
2. the last calculation for x and y are held over in memory for the next 
overlay, resulting in offsets and drift over time.
3. occasionally one frame of the gif appears again, outside the range 
given in between, in addition to the frames shown at the correct time 
(ignoring the 33.333/30 drift).
4. occasionally one frame inside that range specified in between, is 
left out or skipped.

I made an extensive list of when some or all of the above are seen and 
repeatable. It is in the comments at the end of the .sh file. The 
test1.sh version only loaded one video and one gif file, and thus only 
saw problem #1. By adding a second gif with different color, (this 
test2.sh) then the flashes of the single frame can be identified to it's 
parent. The script generates the test-run "2n" where an orange flash is 
at frame 408 and a red flash at frame 571. If my comments are unclear, 
just ask.

Procedure to duplicate:
$ ./build-test2.sh p
  for the perfect png version, which duplicates everything except the 
input file type, and then for the gif version, here is the full output 
as always requested:
$ ./build-test2.sh

ffmpeg version N-96573-g73aab08d9d Copyright (c) 2000-2020 the FFmpeg 
developers
   built with gcc 6.3.0 (Debian 6.3.0-18+deb9u1) 20170516
   configuration: --prefix=/usr/local --enable-gpl --enable-libmp3lame 
--enable-libvorbis --enable-libx264 --enable-libopenjpeg 
--enable-libfreetype --disable-doc --disable-htmlpages 
--disable-podpages --enable-shared --enable-libvpx 
--extra-cflags=-I/usr/include --extra-ldflags=-L/usr/lib/i386-linux-gnu 
--enable-libass --enable-libtesseract --extra-cflags=-msse2 
--enable-openssl --enable-nonfree
   libavutil      56. 38.100 / 56. 36.101
   libavcodec     58. 67.100 / 58. 64.101
   libavformat    58. 37.100 / 58. 35.101
   libavdevice    58.  9.103 / 58.  9.101
   libavfilter     7. 72.100 /  7. 68.100
   libswscale      5.  6.100 /  5.  6.100
   libswresample   3.  6.100 /  3.  6.100
   libpostproc    55.  6.100 / 55.  6.100
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x180e140] st: 0 edit list: 1 Missing key 
frame while searching for timestamp: 2000
[mov,mp4,m4a,3gp,3g2,mj2 @ 0x180e140] st: 0 edit list 1 Cannot find an 
index entry before timestamp: 2000.
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 
'20190628_163959_driving-WCurlewLkRd-S_30sec_FHDw.MOV':
   Metadata:
     major_brand     : qt
     minor_version   : 0
     compatible_brands: qt
     creation_time   : 2019-06-28T16:39:59.000000Z
     playback_requirements: QuickTime 6.0 or greater
     playback_requirements-eng: QuickTime 6.0 or greater
   Duration: 00:00:29.50, start: 0.000000, bitrate: 15212 kb/s
     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 
1920x1080, 15078 kb/s, 30 fps, 30 tbr, 60k tbn, 120k tbc (default)
     Metadata:
       creation_time   : 2019-06-28T16:39:59.000000Z
       handler_name    : Video Handler
       encoder         : iCatch AVCC
     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, fltp, 127 kb/s (default)
     Metadata:
       creation_time   : 2019-06-28T16:39:59.000000Z
       handler_name    : Audio Handler
Input #1, gif, from 'redwave-500x400.gif':
   Duration: 00:00:01.35, start: 0.000000, bitrate: 2635 kb/s
     Stream #1:0: Video: gif, bgra, 500x400, 34 fps, 100 tbr, 100 tbn, 
100 tbc
Input #2, gif, from 'orangewave-500x400.gif':
   Duration: 00:00:01.35, start: 0.000000, bitrate: 2635 kb/s
     Stream #2:0: Video: gif, bgra, 500x400, 34 fps, 100 tbr, 100 tbn, 
100 tbc
Stream mapping:
   Stream #0:0 (h264) -> scale (graph 0)
   Stream #1:0 (gif) -> split (graph 0)
   Stream #2:0 (gif) -> overlay:overlay (graph 0)
   drawtext (graph 0) -> Stream #0:0 (libx264)
   Stream #0:1 -> #0:1 (aac (native) -> aac (native))
Press [q] to stop, [?] for help
[libx264 @ 0x18d2bc0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 
AVX LZCNT BMI1 SlowPshufb
[libx264 @ 0x18d2bc0] profile High, level 3.1
[libx264 @ 0x18d2bc0] 264 - core 148 r2748 97eaef2 - 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=6 
lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 
bluray_compat=0 constrained_intra=0 bframes=2 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=18.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 
aq=1:1.00
Output #0, mp4, to 'test2-out-gif-720e.mp4':
   Metadata:
     major_brand     : qt
     minor_version   : 0
     compatible_brands: qt
     playback_requirements-eng: QuickTime 6.0 or greater
     playback_requirements: QuickTime 6.0 or greater
     encoder         : Lavf58.35.101
     Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 
1280x720, q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
     Metadata:
       encoder         : Lavc58.67.100 libx264
     Side data:
       cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
     Stream #0:1(eng): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, 
stereo, fltp, 128 kb/s (default)
     Metadata:
       creation_time   : 2019-06-28T16:39:59.000000Z
       handler_name    : Audio Handler
       encoder         : Lavc58.67.100 aac
[mp4 @ 0x18d2100] Starting second pass: moving the moov atom to the 
beginning of the file0.181x
frame=  840 fps=5.3 q=-1.0 Lsize=   42273kB time=00:00:28.01 
bitrate=12363.2kbits/s speed=0.177x
video:41964kB audio:280kB subtitle:0kB other streams:0kB global 
headers:0kB muxing overhead: 0.070744%
[libx264 @ 0x18d2bc0] frame I:56    Avg QP:17.71  size:150429
[libx264 @ 0x18d2bc0] frame P:280   Avg QP:20.84  size: 63961
[libx264 @ 0x18d2bc0] frame B:504   Avg QP:23.72  size: 33010
[libx264 @ 0x18d2bc0] consecutive B-frames:  6.7% 13.3% 80.0%
[libx264 @ 0x18d2bc0] mb I  I16..4:  5.9% 56.3% 37.9%
[libx264 @ 0x18d2bc0] mb P  I16..4:  0.9% 13.0%  6.1%  P16..4: 32.6% 
22.7% 15.8%  0.0%  0.0%    skip: 9.0%
[libx264 @ 0x18d2bc0] mb B  I16..4:  0.1%  2.1%  1.9%  B16..8: 39.2% 
14.6%  7.8%  direct: 4.2%  skip:30.0%  L0:43.9% L1:36.4% BI:19.7%
[libx264 @ 0x18d2bc0] 8x8 transform intra:59.4% inter:60.1%
[libx264 @ 0x18d2bc0] coded y,uvDC,uvAC intra: 92.6% 93.1% 68.5% inter: 
35.9% 38.0% 9.1%
[libx264 @ 0x18d2bc0] i16 v,h,dc,p:  6% 33%  4% 56%
[libx264 @ 0x18d2bc0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 10% 26% 13% 6%  8%  
7% 10%  7% 14%
[libx264 @ 0x18d2bc0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 11% 28% 10% 7%  9%  
7% 11%  6% 11%
[libx264 @ 0x18d2bc0] i8c dc,h,v,p: 47% 31% 12%  9%
[libx264 @ 0x18d2bc0] Weighted P-Frames: Y:6.1% UV:2.1%
[libx264 @ 0x18d2bc0] ref P L0: 62.6% 14.8% 16.1%  6.2%  0.2%
[libx264 @ 0x18d2bc0] ref B L0: 80.8% 16.5%  2.7%
[libx264 @ 0x18d2bc0] kb/s:12277.17
[aac @ 0x18d0f40] Qavg: 118.000

Stewart



More information about the ffmpeg-user mailing list