Opened 19 months ago

Last modified 9 months ago

#8985 open defect

GIF overlay blinks when added as a layer

Reported by: emaincourt Owned by:
Priority: important Component: avfilter
Version: git-master Keywords: gif overlay regression
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:

When adding a GIF overlay to an MP4 video, with enable option set, the GIF blinks before disappearing. Actually what happens when I take a look at the encoded output frame by frame is that the GIF disappears from the timeline a few milliseconds before 3s, then appears again and eventually leaves.

So far, I've always been facing this bug when using GIFs from Giphy. Other GIFs that I had locally seem to be ok.

Please find here a demonstration of that behaviour.

How to reproduce:

% ffmpeg \                                                                                     
  -i 0689a8a9-43b5-45d2-b0e8-acbea6905ce1.mp4 \
  -ignore_loop 0 \
  -i 02a6e696-969b-4a90-9444-e4b0b4d6f6da.gif \
  -t 10.000000 \
  -filter_complex "[0:v][1:v]overlay=enable='between(t, 1, 3)'" \
  -pix_fmt yuv420p \
  output.mp4
ffmpeg version 4.3.1 Copyright (c) 2000-2020 the FFmpeg developers
  built with Apple clang version 12.0.0 (clang-1200.0.32.21)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/4.3.1_2 --enable-shared --enable-pthreads --enable-version3 --enable-avresample --cc=clang --host-cflags= --host-ldflags= --enable-ffplay --enable-gnutls --enable-gpl --enable-libaom --enable-libbluray --enable-libdav1d --enable-libmp3lame --enable-libopus --enable-librav1e --enable-librubberband --enable-libsnappy --enable-libsrt --enable-libtesseract --enable-libtheora --enable-libvidstab --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libx264 --enable-libx265 --enable-libxml2 --enable-libxvid --enable-lzma --enable-libfontconfig --enable-libfreetype --enable-frei0r --enable-libass --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-librtmp --enable-libspeex --enable-libsoxr --enable-videotoolbox --disable-libjack --disable-indev=jack
  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 '0689a8a9-43b5-45d2-b0e8-acbea6905ce1.mp4':
  Metadata:
    major_brand     : isom
    minor_version   : 512
    compatible_brands: isomiso2avc1mp41
    encoder         : Lavf57.56.101
  Duration: 00:00:10.00, start: 0.000000, bitrate: 21 kb/s
    Stream #0:0(und): Video: h264 (High 4:4:4 Predictive) (avc1 / 0x31637661), yuv444p, 1920x1080 [SAR 1:1 DAR 16:9], 18 kb/s, 30 fps, 30 tbr, 15360 tbn, 60 tbc (default)
    Metadata:
      handler_name    : VideoHandler
Input #1, gif, from '02a6e696-969b-4a90-9444-e4b0b4d6f6da.gif':
  Duration: 00:00:01.20, start: 0.000000, bitrate: 1437 kb/s
    Stream #1:0: Video: gif, bgra, 480x279, 7.42 fps, 6.58 tbr, 100 tbn, 100 tbc
Stream mapping:
  Stream #0:0 (h264) -> overlay:main
  Stream #1:0 (gif) -> overlay:overlay
  overlay -> Stream #0:0 (libx264)
Press [q] to stop, [?] for help
[libx264 @ 0x7f997c80a800] using SAR=1/1
[libx264 @ 0x7f997c80a800] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x7f997c80a800] profile High, level 4.0, 4:2:0, 8-bit
[libx264 @ 0x7f997c80a800] 264 - core 161 r3018M db0d417 - H.264/MPEG-4 AVC codec - Copyleft 2003-2020 - 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=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         : Lavf58.45.100
    Stream #0:0: Video: h264 (libx264) (avc1 / 0x31637661), yuv420p, 1920x1080 [SAR 1:1 DAR 16:9], q=-1--1, 30 fps, 15360 tbn, 30 tbc (default)
    Metadata:
      encoder         : Lavc58.91.100 libx264
    Side data:
      cpb: bitrate max/min/avg: 0/0/0 buffer size: 0 vbv_delay: N/A
frame=  300 fps= 62 q=-1.0 Lsize=      69kB time=00:00:09.90 bitrate=  57.1kbits/s speed=2.05x
video:65kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 6.697149%
[libx264 @ 0x7f997c80a800] frame I:2     Avg QP: 8.70  size:  7746
[libx264 @ 0x7f997c80a800] frame P:76    Avg QP:12.24  size:   433
[libx264 @ 0x7f997c80a800] frame B:222   Avg QP:14.13  size:    77
[libx264 @ 0x7f997c80a800] consecutive B-frames:  1.0%  0.0%  3.0% 96.0%
[libx264 @ 0x7f997c80a800] mb I  I16..4: 89.9%  8.4%  1.7%
[libx264 @ 0x7f997c80a800] mb P  I16..4:  0.2%  0.0%  0.0%  P16..4:  0.2%  0.0%  0.0%  0.0%  0.0%    skip:99.6%
[libx264 @ 0x7f997c80a800] mb B  I16..4:  0.0%  0.0%  0.0%  B16..8:  0.2%  0.0%  0.0%  direct: 0.0%  skip:99.8%  L0:52.6% L1:47.3% BI: 0.1%
[libx264 @ 0x7f997c80a800] 8x8 transform intra:9.2% inter:34.0%
[libx264 @ 0x7f997c80a800] coded y,uvDC,uvAC intra: 2.6% 3.0% 2.5% inter: 0.0% 0.0% 0.0%
[libx264 @ 0x7f997c80a800] i16 v,h,dc,p: 98%  1%  2%  0%
[libx264 @ 0x7f997c80a800] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 62% 20% 16%  0%  0%  0%  0%  1%  0%
[libx264 @ 0x7f997c80a800] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 31% 23% 14%  4%  3%  8%  4%  8%  4%
[libx264 @ 0x7f997c80a800] i8c dc,h,v,p: 96%  2%  2%  0%
[libx264 @ 0x7f997c80a800] Weighted P-Frames: Y:2.6% UV:2.6%
[libx264 @ 0x7f997c80a800] ref P L0: 23.3%  3.8% 33.7% 39.2%
[libx264 @ 0x7f997c80a800] ref B L0: 89.6%  9.8%  0.6%
[libx264 @ 0x7f997c80a800] ref B L1: 98.9%  1.1%
[libx264 @ 0x7f997c80a800] kb/s:52.46

Attachments (2)

02a6e696-969b-4a90-9444-e4b0b4d6f6da.gif (210.5 KB ) - added by emaincourt 19 months ago.
0689a8a9-43b5-45d2-b0e8-acbea6905ce1.mp4 (26.5 KB ) - added by emaincourt 19 months ago.

Download all attachments as: .zip

Change History (4)

comment:1 by Carl Eugen Hoyos, 19 months ago

Component: undeterminedavfilter
Keywords: overlay regression added
Priority: normalimportant
Reproduced by developer: set
Status: newopen
Version: unspecifiedgit-master

For future tickets: Please remember to test current FFmpeg git head before reporting an issue here.

Regression since 231e50157cc9a7a8b08ba3d0e566279fc6cbb800

comment:2 by Elon Musk, 9 months ago

Workaround is to use fps=30 for gif stream prior to overlay filter.

Note: See TracTickets for help on using tickets.