Opened 3 years ago

Closed 3 years ago

#4235 closed defect (fixed)

Converting GIF to MP4 using FFmpeg produces a video that doesn't follow the GIF frame timings.

Reported by: dvir Owned by:
Priority: normal Component: ffmpeg
Version: 2.3.5 Keywords: gif
Cc: Blocked By:
Blocking: Reproduced by developer: yes
Analyzed by developer: no

Description

Summary of the bug:
Converting GIF to MP4 using FFmpeg produces a video that doesn't follow the GIF frame timings.

I'm using FFmpeg to convert a GIF into an MP4, with the following command:
ffmpeg -f gif -i ~/transparent.gif -c:v libx264 -f mp4 ./transparent.mp4

This is the input GIF: http://media.giphy.com/media/lXiRla43JDySJhTLW/giphy.gif
This is the the output mp4: https://vid.me/aGv6

it seems like FFmpeg is skipping the first frame of the GIF, and skips the timing for the last frame (the first and last frame are 2000ms long, yet it doesn't halt at the end like it does in the beginning).

The frame timings are: (produced with ImageMagick? -- 'identify -format '%T|' ~/transparent.gif')
200|5|5|5|5|10|10|10|10|10|10|10|200

This means the first frame should be 2000ms long, and so is the last one. For the last frame, the timing is messed (doesn't half for 2000ms), and it seems to skip the first frame, which doesn't show the metal hand. You could look at the input GIF and see that it is different from the product MP4.

How to reproduce:
Re-run the command described above on the input GIF linked to above.

Verbose input file information:

% dvir-mbp1:tmp dvir$ ffmpeg -v 9 -loglevel 99 -i ~/transparent.gif 
ffmpeg version 2.3.3 Copyright (c) 2000-2014 the FFmpeg developers
  built on Aug 25 2014 19:47:15 with Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
  configuration: --prefix=/usr/local/Cellar/ffmpeg/2.3.3 --enable-shared --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree --enable-hardcoded-tables --enable-avresample --enable-vda --cc=clang --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-libmp3lame --enable-libxvid
  libavutil      52. 92.100 / 52. 92.100
  libavcodec     55. 69.100 / 55. 69.100
  libavformat    55. 48.100 / 55. 48.100
  libavdevice    55. 13.102 / 55. 13.102
  libavfilter     4. 11.100 /  4. 11.100
  libavresample   1.  3.  0 /  1.  3.  0
  libswscale      2.  6.100 /  2.  6.100
  libswresample   0. 19.100 /  0. 19.100
  libpostproc    52.  3.100 / 52.  3.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-i' ... matched as input file with argument '/Users/dvir/transparent.gif'.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Successfully parsed a group of options.
Parsing a group of options: input file /Users/dvir/transparent.gif.
Successfully parsed a group of options.
Opening an input file: /Users/dvir/transparent.gif.
[gif @ 0x7fa549800000] Format gif probed with size=2048 and score=100
[gif @ 0x7fa549800000] Before avformat_find_stream_info() pos: 0 bytes read:3233 seeks:0
rfps: 19.583333 0.014962
rfps: 19.666667 0.009576
    Last message repeated 1 times
rfps: 19.750000 0.005386
rfps: 19.833333 0.002394
    Last message repeated 1 times
rfps: 19.916667 0.000598
    Last message repeated 1 times
rfps: 20.000000 0.000000
rfps: 20.083333 0.000598
    Last message repeated 1 times
rfps: 20.166667 0.002394
    Last message repeated 1 times
rfps: 20.250000 0.005386
rfps: 20.333333 0.009576
    Last message repeated 1 times
rfps: 20.416667 0.014962
rfps: 39.583333 0.014962
rfps: 39.666667 0.009576
    Last message repeated 1 times
rfps: 39.750000 0.005386
rfps: 39.833333 0.002394
    Last message repeated 1 times
rfps: 39.916667 0.000598
    Last message repeated 1 times
rfps: 40.000000 0.000000
rfps: 40.083333 0.000598
    Last message repeated 1 times
rfps: 40.166667 0.002394
    Last message repeated 1 times
rfps: 40.250000 0.005386
rfps: 40.333333 0.009576
    Last message repeated 1 times
rfps: 40.416667 0.014962
rfps: 59.583333 0.014962
rfps: 59.666667 0.009576
    Last message repeated 1 times
rfps: 59.750000 0.005386
rfps: 59.833333 0.002394
    Last message repeated 1 times
rfps: 59.916667 0.000598
    Last message repeated 1 times
rfps: 60.000000 0.000000
rfps: 59.940060 0.000310
    Last message repeated 1 times
[gif @ 0x7fa549800000] After avformat_find_stream_info() pos: 3233 bytes read:3233 seeks:0 frames:13
Input #0, gif, from '/Users/dvir/transparent.gif':
  Duration: N/A, bitrate: N/A
    Stream #0:0, 13, 1/100: Video: gif, bgra, 50x32, 1/100, 3.83 fps, 20 tbr, 100 tbn, 100 tbc
Successfully opened the file.
At least one output file must be specified
[AVIOContext @ 0x7fa548e00140] Statistics: 3233 bytes read, 0 seeks

Change History (1)

comment:1 Changed 3 years ago by michael

  • Reproduced by developer set
  • Resolution set to fixed
  • Status changed from new to closed

The first frame looks different with git master, thus i think this has been fixed

Note: See TracTickets for help on using tickets.