0

I am playing with ffmpeg libs, namely libswscale and libavcodec for now. My goal is resize GIF files. From my ridiculous understanding, I think I need to

  • decode the GIF and get an AVFrame
  • process the frame with libswscale
  • encode again into GIF

But I am stuck at step 1. Based on official sample at https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/decode_video.c , I need to get a parser:

codec = avcodec_find_decoder(AV_CODEC_ID_GIF);
parser = av_parser_init(codec->id);

But no parser is found. I am not touching parser in my configure call, so I take all:

Enabled parsers:
aac                       cavsvideo                 dvbsub                    h263                      mpegvideo                 sipr                      xma
aac_latm                  cook                      dvd_nav                   h264                      opus                      tak
ac3                       dca                       dvdsub                    hevc                      png                       vc1
adx                       dirac                     flac                      mjpeg                     pnm                       vorbis
av1                       dnxhd                     g729                      mlp                       rv30                      vp3
avs2                      dpx                       gsm                       mpeg4video                rv40                      vp8
bmp                       dvaudio                   h261                      mpegaudio                 sbc                       vp9

What am I doing wrong? If this is the wrong approach, what is the correct one?

natario
  • 24,954
  • 17
  • 88
  • 158
  • (to close voter) How is it unclear what I am asking? I am asking why there's no parser that handles `AV_CODEC_ID_GIF`, but also giving context around this because the whole approach I took might be wrong for my goal. I just don't know. – natario Nov 24 '18 at 18:13
  • Maybe [this](https://stackoverflow.com/a/4091983/3871028) helps. And [docs](https://ffmpeg.org/doxygen/2.8/group__lavc__core.html#gaf1a2bb4e7c7611c131bb6212bf0fa639) – Ripi2 Nov 24 '18 at 18:29
  • @Ripi2 thanks. But I am using ffmpeg 4.1 where this function is deprecated and is a no-op. Even if I add nothing changes. It's not clear to me which one (in the list I attached) should be the correct parser for gifs. Apparently no-one? – natario Nov 24 '18 at 18:38
  • No parser needed for GIF. The decoder parses the bitstream for the next image or extension. – Gyan Nov 24 '18 at 18:59
  • Thanks @Gyan . How to use the decoder then? I was following lines 161-171 from the [official sample](https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/decode_video.c). Feel free to post an answer – natario Nov 24 '18 at 19:09
  • You can't. You'll need to use a demuxer to generate packets, so try https://github.com/FFmpeg/FFmpeg/blob/master/doc/examples/demuxing_decoding.c – Gyan Nov 24 '18 at 19:18
  • @Gyan So is a GIF requiring more work than a video? The sample was reading packets from a video file... And a GIF has no audio so why demuxing? I'm confused. – natario Nov 24 '18 at 19:32
  • GIF comes in its own format, which requires a demuxer. Then straight from demuxer to decoder with no parser in between. If there's no audio, those codepaths won't be followed. – Gyan Nov 24 '18 at 20:04

0 Answers0