[FFmpeg-trac] #2936(avformat:open): %-syntax for GIF output is not respected, can't write individual frames as images

FFmpeg trac at avcodec.org
Tue Sep 3 17:37:13 CEST 2013


#2936: %-syntax for GIF output is not respected, can't write individual frames as
images
------------------------------------+------------------------------------
             Reporter:  slhck       |                    Owner:
                 Type:  defect      |                   Status:  open
             Priority:  normal      |                Component:  avformat
              Version:  git-master  |               Resolution:
             Keywords:  gif         |               Blocked By:
             Blocking:              |  Reproduced by developer:  1
Analyzed by developer:  1           |
------------------------------------+------------------------------------

Old description:

> Recent ffmpeg does not correctly create individual GIF files. For
> example, I expect this to output one .gif file for each frame:
>
> {{{
> ffmpeg -i input output%04d.gif
> }}}
>
> This works in ffmpeg 1.2.1, but it only creates a file called
> `output%04d.gif` for newer versions.
>
> This creates a file literally called `output%04d.gif`:
> {{{
> ± % ./ffmpeg -i input.mp4 output%04d.gif
> ffmpeg version N-55996-g916549c Copyright (c) 2000-2013 the FFmpeg
> developers
>   built on Sep  3 2013 16:43:43 with llvm-gcc 4.2.1 (LLVM build
> 2336.11.00)
>   configuration: --enable-gpl --enable-version3 --enable-nonfree
> --enable-postproc
>   libavutil      52. 43.100 / 52. 43.100
>   libavcodec     55. 31.100 / 55. 31.100
>   libavformat    55. 15.100 / 55. 15.100
>   libavdevice    55.  3.100 / 55.  3.100
>   libavfilter     3. 83.101 /  3. 83.101
>   libswscale      2.  5.100 /  2.  5.100
>   libswresample   0. 17.103 /  0. 17.103
>   libpostproc    52.  3.100 / 52.  3.100
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
>   Metadata:
>     major_brand     : isom
>     minor_version   : 512
>     compatible_brands: isomiso2avc1mp41
>     creation_time   : 2012-01-08 11:16:19
>     encoder         : John Doe for ID 14077
>   Duration: 00:03:31.58, start: 0.000000, bitrate: 2359 kb/s
>     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> 1280x720 [SAR 1:1 DAR 16:9], 2229 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
> (default)
>     Metadata:
>       creation_time   : 2012-01-08 11:16:19
>       handler_name    : VideoHandler
>     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
> fltp, 125 kb/s (default)
>     Metadata:
>       creation_time   : 2012-01-08 11:16:19
>       handler_name    : SoundHandler
> [swscaler @ 0x7ff76d000a00] No accelerated colorspace conversion found
> from yuv420p to bgr8.
> Output #0, gif, to 'output%04d.gif':
>   Metadata:
>     major_brand     : isom
>     minor_version   : 512
>     compatible_brands: isomiso2avc1mp41
>     encoder         : Lavf55.15.100
>     Stream #0:0(eng): Video: gif, bgr8, 1280x720 [SAR 1:1 DAR 16:9],
> q=2-31, 200 kb/s, 100 tbn, 25 tbc (default)
>     Metadata:
>       creation_time   : 2012-01-08 11:16:19
>       handler_name    : VideoHandler
> Stream mapping:
>   Stream #0:0 -> #0:0 (h264 -> gif)
> Press [q] to stop, [?] for help
> frame=  147 fps= 51 q=-1.0 Lsize=   24214kB time=00:00:05.88
> bitrate=33734.8kbits/s
> video:24360kB audio:0kB subtitle:0 global headers:0kB muxing overhead
> -0.599030%
> }}}
>
> This works in 1.2.1, and it creates individual files for each frame:
>
> {{{
> ± % ffmpeg -i input.mp4 output%04d.gif
> ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
>   built on Jul 24 2013 20:10:19 with Apple LLVM version 4.2
> (clang-425.0.28) (based on LLVM 3.2svn)
>   configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared
> --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree
> --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc
> --host-cflags= --host-ldflags= --enable-libx264 --enable-libfaac
> --enable-libmp3lame --enable-libxvid --enable-libfreetype --enable-
> libtheora --enable-libvorbis --enable-libvpx --enable-librtmp --enable-
> libopencore-amrnb --enable-libopencore-amrwb --enable-libvo-aacenc
> --enable-libass --enable-ffplay --enable-libspeex --enable-
> libschroedinger --enable-libfdk-aac --enable-libopus --enable-frei0r
> --enable-libcaca --enable-libopenjpeg --extra-
> cflags='-I/usr/local/Cellar/openjpeg/1.5.1/include/openjpeg-1.5 '
>   libavutil      52. 18.100 / 52. 18.100
>   libavcodec     54. 92.100 / 54. 92.100
>   libavformat    54. 63.104 / 54. 63.104
>   libavdevice    54.  3.103 / 54.  3.103
>   libavfilter     3. 42.103 /  3. 42.103
>   libswscale      2.  2.100 /  2.  2.100
>   libswresample   0. 17.102 /  0. 17.102
>   libpostproc    52.  2.100 / 52.  2.100
> Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
>   Metadata:
>     major_brand     : isom
>     minor_version   : 512
>     compatible_brands: isomiso2avc1mp41
>     creation_time   : 2012-01-08 11:16:19
>     encoder         : John Doe for ID 14077
>   Duration: 00:03:31.58, start: 0.000000, bitrate: 2359 kb/s
>     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
> 1280x720 [SAR 1:1 DAR 16:9], 2229 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
>     Metadata:
>       creation_time   : 2012-01-08 11:16:19
>       handler_name    : VideoHandler
>     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
> fltp, 125 kb/s
>     Metadata:
>       creation_time   : 2012-01-08 11:16:19
>       handler_name    : SoundHandler
> [swscaler @ 0x7fd2e987b800] No accelerated colorspace conversion found
> from yuv420p to bgr8.
> [swscaler @ 0x7fd2e9882c00] No accelerated colorspace conversion found
> from yuv420p to bgr8.
> [swscaler @ 0x7fd2e9847a00] No accelerated colorspace conversion found
> from yuv420p to bgr8.
> Output #0, image2, to 'output%04d.gif':
>   Metadata:
>     major_brand     : isom
>     minor_version   : 512
>     compatible_brands: isomiso2avc1mp41
>     encoder         : Lavf54.63.104
>     Stream #0:0(eng): Video: gif, bgr8, 1280x720 [SAR 1:1 DAR 16:9],
> q=2-31, 200 kb/s, 90k tbn, 25 tbc
>     Metadata:
>       creation_time   : 2012-01-08 11:16:19
>       handler_name    : VideoHandler
> Stream mapping:
>   Stream #0:0 -> #0:0 (h264 -> gif)
> Press [q] to stop, [?] for help
> frame=  135 fps= 51 q=0.0 Lsize=N/A time=00:00:05.40 bitrate=N/A
> video:27300kB audio:0kB subtitle:0 global headers:0kB muxing overhead
> -100.000079%
> }}}

New description:

 Recent ffmpeg does not correctly create individual GIF files. For example,
 I expect this to output one .gif file for each frame:

 {{{
 ffmpeg -i input output%04d.gif
 }}}

 This works in ffmpeg 1.2.1, but it only creates a file called
 `output%04d.gif` for newer versions.

 This creates a file literally called `output%04d.gif`:
 {{{
 +- % ./ffmpeg -i input.mp4 output%04d.gif
 ffmpeg version N-55996-g916549c Copyright (c) 2000-2013 the FFmpeg
 developers
   built on Sep  3 2013 16:43:43 with llvm-gcc 4.2.1 (LLVM build
 2336.11.00)
   configuration: --enable-gpl --enable-version3 --enable-nonfree --enable-
 postproc
   libavutil      52. 43.100 / 52. 43.100
   libavcodec     55. 31.100 / 55. 31.100
   libavformat    55. 15.100 / 55. 15.100
   libavdevice    55.  3.100 / 55.  3.100
   libavfilter     3. 83.101 /  3. 83.101
   libswscale      2.  5.100 /  2.  5.100
   libswresample   0. 17.103 /  0. 17.103
   libpostproc    52.  3.100 / 52.  3.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     creation_time   : 2012-01-08 11:16:19
     encoder         : John Doe for ID 14077
   Duration: 00:03:31.58, start: 0.000000, bitrate: 2359 kb/s
     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
 1280x720 [SAR 1:1 DAR 16:9], 2229 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
 (default)
     Metadata:
       creation_time   : 2012-01-08 11:16:19
       handler_name    : VideoHandler
     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
 fltp, 125 kb/s (default)
     Metadata:
       creation_time   : 2012-01-08 11:16:19
       handler_name    : SoundHandler
 [swscaler @ 0x7ff76d000a00] No accelerated colorspace conversion found
 from yuv420p to bgr8.
 Output #0, gif, to 'output%04d.gif':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf55.15.100
     Stream #0:0(eng): Video: gif, bgr8, 1280x720 [SAR 1:1 DAR 16:9],
 q=2-31, 200 kb/s, 100 tbn, 25 tbc (default)
     Metadata:
       creation_time   : 2012-01-08 11:16:19
       handler_name    : VideoHandler
 Stream mapping:
   Stream #0:0 -> #0:0 (h264 -> gif)
 Press [q] to stop, [?] for help
 frame=  147 fps= 51 q=-1.0 Lsize=   24214kB time=00:00:05.88
 bitrate=33734.8kbits/s
 video:24360kB audio:0kB subtitle:0 global headers:0kB muxing overhead
 -0.599030%
 }}}

 This works in 1.2.1, and it creates individual files for each frame:

 {{{
 +- % ffmpeg -i input.mp4 output%04d.gif
 ffmpeg version 1.2.1 Copyright (c) 2000-2013 the FFmpeg developers
   built on Jul 24 2013 20:10:19 with Apple LLVM version 4.2
 (clang-425.0.28) (based on LLVM 3.2svn)
   configuration: --prefix=/usr/local/Cellar/ffmpeg/1.2.1 --enable-shared
 --enable-pthreads --enable-gpl --enable-version3 --enable-nonfree
 --enable-hardcoded-tables --enable-avresample --enable-vda --cc=cc --host-
 cflags= --host-ldflags= --enable-libx264 --enable-libfaac --enable-
 libmp3lame --enable-libxvid --enable-libfreetype --enable-libtheora
 --enable-libvorbis --enable-libvpx --enable-librtmp --enable-libopencore-
 amrnb --enable-libopencore-amrwb --enable-libvo-aacenc --enable-libass
 --enable-ffplay --enable-libspeex --enable-libschroedinger --enable-
 libfdk-aac --enable-libopus --enable-frei0r --enable-libcaca --enable-
 libopenjpeg --extra-
 cflags='-I/usr/local/Cellar/openjpeg/1.5.1/include/openjpeg-1.5 '
   libavutil      52. 18.100 / 52. 18.100
   libavcodec     54. 92.100 / 54. 92.100
   libavformat    54. 63.104 / 54. 63.104
   libavdevice    54.  3.103 / 54.  3.103
   libavfilter     3. 42.103 /  3. 42.103
   libswscale      2.  2.100 /  2.  2.100
   libswresample   0. 17.102 /  0. 17.102
   libpostproc    52.  2.100 / 52.  2.100
 Input #0, mov,mp4,m4a,3gp,3g2,mj2, from 'input.mp4':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     creation_time   : 2012-01-08 11:16:19
     encoder         : John Doe for ID 14077
   Duration: 00:03:31.58, start: 0.000000, bitrate: 2359 kb/s
     Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p,
 1280x720 [SAR 1:1 DAR 16:9], 2229 kb/s, 25 fps, 25 tbr, 25 tbn, 50 tbc
     Metadata:
       creation_time   : 2012-01-08 11:16:19
       handler_name    : VideoHandler
     Stream #0:1(eng): Audio: aac (mp4a / 0x6134706D), 48000 Hz, stereo,
 fltp, 125 kb/s
     Metadata:
       creation_time   : 2012-01-08 11:16:19
       handler_name    : SoundHandler
 [swscaler @ 0x7fd2e987b800] No accelerated colorspace conversion found
 from yuv420p to bgr8.
 [swscaler @ 0x7fd2e9882c00] No accelerated colorspace conversion found
 from yuv420p to bgr8.
 [swscaler @ 0x7fd2e9847a00] No accelerated colorspace conversion found
 from yuv420p to bgr8.
 Output #0, image2, to 'output%04d.gif':
   Metadata:
     major_brand     : isom
     minor_version   : 512
     compatible_brands: isomiso2avc1mp41
     encoder         : Lavf54.63.104
     Stream #0:0(eng): Video: gif, bgr8, 1280x720 [SAR 1:1 DAR 16:9],
 q=2-31, 200 kb/s, 90k tbn, 25 tbc
     Metadata:
       creation_time   : 2012-01-08 11:16:19
       handler_name    : VideoHandler
 Stream mapping:
   Stream #0:0 -> #0:0 (h264 -> gif)
 Press [q] to stop, [?] for help
 frame=  135 fps= 51 q=0.0 Lsize=N/A time=00:00:05.40 bitrate=N/A
 video:27300kB audio:0kB subtitle:0 global headers:0kB muxing overhead
 -100.000079%
 }}}

--

Comment (by richardpl):

 It should be possible to write separate gifs for each frame with image2
 muxer if there is some way to signal such request to gif encoder.

-- 
Ticket URL: <https://ffmpeg.org/trac/ffmpeg/ticket/2936#comment:5>
FFmpeg <http://ffmpeg.org>
FFmpeg issue tracker


More information about the FFmpeg-trac mailing list