Search code examples
ffmpegandroid-ffmpeg

What encoders/decoders/muxers/demuxers/parsers do I need to enable in FFMpeg for converting an mp4 video to a gif?


I am building FFMpeg with custom options to reduce the final size of .so files on android. I want to convert a mp4 file to a gif. Some options I have already set as I am doing some other processing on mp4 video and aac audio. Now I am stuck at successfully converting a mp4 video to gif.

Following is my options specified

 --disable-everything
 --enable-decoder=mpeg4,mpegvideo,aac,gif
 --enable-parser=aac,mpeg4video,mpegaudio,mpegvideo,gif
 --enable-demuxer=mpegvideo,aac,mov,gif
 --enable-muxer=mp4,gif,mov
 --enable-protocol=file
 --enable-encoder=mpeg4,mov,gif
 --enable-filter=scale,fps,copy,palettegen,vflip,paletteuse,crop

What other options do i need to add to successfully run this command?

ffmpeg -y -i input.mp4 -vf "fps=15,scale=320:-1:flags=lanczos" -pix_fmt rgb24 output.gif

Solution

  • After enabling logs I figured out I was missing decoder for h264. Here is the updated options. Adding h264 to decoder, parser, encoder, demuxer, muxer (though adding to all of them is unnecessary but it works) The combined .so files for arm is less than 3MB.

     --disable-everything
     --enable-decoder=mpeg4,mpegvideo,aac,gif,h264
     --enable-parser=aac,mpeg4video,mpegaudio,mpegvideo,gif,h264
     --enable-demuxer=mpegvideo,aac,mov,gif,h264
     --enable-muxer=mp4,gif,mov,h264
     --enable-protocol=file
     --enable-encoder=mpeg4,mov,gif,h264
     --enable-filter=scale,fps,copy,palettegen,vflip,paletteuse,crop