Opened 9 years ago

Last modified 9 years ago

#4803 new defect

ffmpeg overlay a gif to video using parameter of enable ,will display the gif picture before enable time.

Reported by: taniey Owned by:
Priority: normal Component: undetermined
Version: git-master Keywords: overlay
Cc: Blocked By:
Blocking: Reproduced by developer: no
Analyzed by developer: no

Description

When I use ffmpeg's overlay filter , I find the filter display the gif before enable time, for this instance,
before 48.560sec ,the gif will display a frame and disappear some frames until 48.560sec.
the url of gif my using: http://www.datafilehost.com/d/41fd1b94
the url of log: http://www.datafilehost.com/d/41fd1b94

the command and the output is:

ffmpeg -y  -i '/data/mediadata/source/Ice.Age.Continental.Drift.2012.720sp.mkv' -ignore_loop 0 -i '/data/mediadata/source/gif.gif' -filter_complex "overlay=x=182:y=82:shortest=1:repeatlast=1:enable=between(t\,48.560\,60)[out]" -map [out] -c:v h264 -s 640*360 -b:v 500k -t 00:01:00.000 'v_8JnNXs.mkv'
ffmpeg version 2.7.2-static http://johnvansickle.com/ffmpeg/  Copyright (c) 2000-2015 the FFmpeg developers
  built with gcc 4.9.3 (Debian 4.9.3-1)
  configuration: --enable-gpl --enable-version3 --disable-shared --disable-debug --enable-runtime-cpudetect --enable-libmp3lame --enable-libx264 --enable-libx265 --enable-libwebp --enable-libspeex --enable-libvorbis --enable-libvpx --enable-libfreetype --enable-fontconfig --enable-libxvid --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libtheora --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-gray --enable-libopenjpeg --enable-libopus --enable-libass --enable-gnutls --enable-libvidstab --enable-libsoxr --cc=gcc-4.9
  libavutil      54. 27.100 / 54. 27.100
  libavcodec     56. 41.100 / 56. 41.100
  libavformat    56. 36.100 / 56. 36.100
  libavdevice    56.  4.100 / 56.  4.100
  libavfilter     5. 16.101 /  5. 16.101
  libswscale      3.  1.101 /  3.  1.101
  libswresample   1.  2.100 /  1.  2.100
  libpostproc    53.  3.100 / 53.  3.100
Input #0, matroska,webm, from '/data/mediadata/source/Ice.Age.Continental.Drift.2012.720sp.mkv':
  Metadata:
    encoder         : libebml v0.8.0 + libmatroska v0.9.0
    creation_time   : 2012-10-14 03:18:39
  Duration: 01:27:45.34, start: 0.000000, bitrate: 4461 kb/s
    Stream #0:0: Video: h264 (High), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 23.98 fps, 23.98 tbr, 1k tbn, 47.95 tbc (default)
    Stream #0:1: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s (default)
    Metadata:
      title           : 英语
    Stream #0:2: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
    Metadata:
      title           : 国语
    Stream #0:3: Audio: ac3, 48000 Hz, 5.1(side), fltp, 448 kb/s
    Metadata:
      title           : 粤语
    Stream #0:4: Subtitle: ass (default)
    Metadata:
      title           : 中英
    Stream #0:5: Subtitle: ass
    Metadata:
      title           : 英中
    Stream #0:6: Subtitle: subrip
    Metadata:
      title           : 中文
    Stream #0:7: Subtitle: subrip
    Metadata:
      title           : 英文
Input #1, gif, from '/data/mediadata/source/gif.gif':
  Duration: N/A, bitrate: N/A
    Stream #1:0: Video: gif, bgra, 199x220, 2.21 fps, 3.33 tbr, 100 tbn, 100 tbc
[libx264 @ 0x35bc4a0] using SAR=1/1
[libx264 @ 0x35bc4a0] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX
[libx264 @ 0x35bc4a0] profile High, level 3.0
[libx264 @ 0x35bc4a0] 264 - core 146 r109 121396c - 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=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=23 scenecut=40 intra_refresh=0 rc_lookahead=40 rc=abr mbtree=1 bitrate=500 ratetol=1.0 qcomp=0.60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1.40 aq=1:1.00
Output #0, matroska, to 'v_8JnNXs.mkv':
  Metadata:
    encoder         : Lavf56.36.100
    Stream #0:0: Video: h264 (libx264) (H264 / 0x34363248), yuv420p, 640x360 [SAR 1:1 DAR 16:9], q=-1--1, 500 kb/s, 23.98 fps, 1k tbn, 23.98 tbc (default)
    Metadata:
      encoder         : Lavc56.41.100 libx264
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
frame= 1439 fps=172 q=-1.0 Lsize=    3773kB time=00:00:59.93 bitrate= 515.7kbits/s    
video:3762kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 0.286032%
[libx264 @ 0x35bc4a0] frame I:13    Avg QP:13.97  size:  9417
[libx264 @ 0x35bc4a0] frame P:761   Avg QP:18.70  size:  4121
[libx264 @ 0x35bc4a0] frame B:665   Avg QP:21.51  size:   892
[libx264 @ 0x35bc4a0] consecutive B-frames: 30.0% 21.8%  9.8% 38.4%
[libx264 @ 0x35bc4a0] mb I  I16..4: 45.7% 38.8% 15.5%
[libx264 @ 0x35bc4a0] mb P  I16..4:  7.9% 15.6%  2.8%  P16..4: 22.8%  9.2%  4.4%  0.0%  0.0%    skip:37.3%
[libx264 @ 0x35bc4a0] mb B  I16..4:  0.2%  0.7%  0.2%  B16..8: 21.8%  3.7%  0.5%  direct: 1.3%  skip:71.7%  L0:29.5% L1:62.4% BI: 8.1%
[libx264 @ 0x35bc4a0] final ratefactor: 20.23
[libx264 @ 0x35bc4a0] 8x8 transform intra:58.2% inter:72.3%
[libx264 @ 0x35bc4a0] coded y,uvDC,uvAC intra: 36.2% 50.5% 26.6% inter: 10.8% 14.5% 1.7%
[libx264 @ 0x35bc4a0] i16 v,h,dc,p: 34% 41%  6% 19%
[libx264 @ 0x35bc4a0] i8 v,h,dc,ddl,ddr,vr,hd,vl,hu: 26% 21% 28%  3%  4%  3%  6%  3%  5%
[libx264 @ 0x35bc4a0] i4 v,h,dc,ddl,ddr,vr,hd,vl,hu: 33% 23% 16%  4%  6%  4%  7%  4%  3%
[libx264 @ 0x35bc4a0] i8c dc,h,v,p: 57% 27% 12%  4%
[libx264 @ 0x35bc4a0] Weighted P-Frames: Y:15.4% UV:7.4%
[libx264 @ 0x35bc4a0] ref P L0: 67.4% 16.1% 11.9%  4.4%  0.2%
[libx264 @ 0x35bc4a0] ref B L0: 90.6%  8.5%  0.9%
[libx264 @ 0x35bc4a0] ref B L1: 96.2%  3.8%
[libx264 @ 0x35bc4a0] kb/s:513.44

Attachments (1)

gif.gif (29.0 KB ) - added by Carl Eugen Hoyos 9 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 by Carl Eugen Hoyos, 9 years ago

Component: ffmpegundetermined
Keywords: enable removed
Priority: importantnormal
Version: unspecifiedgit-master

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

Are you searching for the -itsoffset option?

$ ffmpeg -f lavfi -i testsrc -itsoffset 48.560 -i gif.gif -filter_complex "overlay=enable=between(t\,48.560\,60)" -t 70 out.avi
Last edited 9 years ago by Carl Eugen Hoyos (previous) (diff)

by Carl Eugen Hoyos, 9 years ago

Attachment: gif.gif added

comment:2 by taniey, 9 years ago

Last edited 9 years ago by taniey (previous) (diff)

in reply to:  1 ; comment:3 by taniey, 9 years ago

Yes ,when I use -itsoffset option, It't right. but between 48.560s and 60s ,there are some frames still can't overlay the gif picture.
I use the command to get all frames between 48s and 60s:

ffmpeg -y -i v_8JnNXs.mkv -ss 00:00:48.000 -r 23.98 -f image2 image-%3d.jpeg

in reply to:  3 ; comment:4 by Carl Eugen Hoyos, 9 years ago

Replying to taniey:

Yes ,when I use -itsoffset option, It't right. but between 48.560s and 60s ,there are some frames still can't overlay the gif picture.

I don't understand, please elaborate.

in reply to:  4 comment:5 by taniey, 9 years ago

Replying to cehoyos:

I use the command

$ ffmpeg -y  -i 'test.mkv' -itsoffset 48.560 -ignore_loop 0 -i '/data/mediadata/source/gif.gif' -filter_complex "overlay=x=182:y=82:shortest=1:repeatlast=0:enable=between(t\,48.560\,60)[out]" -map [out] -c:v h264 -s 640*360 -b:v 500k -t 60  'v_8JnNXs.mkv'

to get output video v_8JnNXs.mkv.

then, I use command

ffmpeg -y -i v_8JnNXs.mkv -ss 00:00:48.000 -r 23.98 -f image2 ./picdir/image-%3d.jpeg

transform all frames in video v_8JnNXs.mkv between 48s and 60s to serial images .
When look all the images,there is no picture be overlaied on image image-274.jpeg

The input file test.mkv url is :http://www.datafilehost.com/d/42e9d283
All the output images url is :http://www.datafilehost.com/d/0bc83c9d

comment:6 by Carl Eugen Hoyos, 9 years ago

Work-around is to encode the overlayed image(s) to a cfr file with the same framerate as the original video as in:

$ ffmpeg -i gif.gif -r 24000/1001 -vcodec qtrle gif.mov
Note: See TracTickets for help on using tickets.