Search code examples
ffmpegh.264android-ffmpeg

Different h264 encoders in FFmpeg


In ffmpeg 4.0, there are several h264 encoders. If you use ./configure --list-encoders | grep "h264", you can see them.

  • h264_amf
  • h264_nvenc
  • h264_omx
  • h264_qsv
  • h264_v4l2m2m
  • h264_vaapi
  • h264_videotoolbox

I do not know what's the difference between. And I want convert local gif to mp4 using ffmpeg, so which encoder works for me?


Solution

  • Each encoder use a different API to access video hardware :

    • h264_amf to access AMD gpu, (windows only)
    • h264_nvenc use nvidia gpu cards (work with windows and linux)
    • h264_omx raspberry pi encoder
    • h264_qsv use Intel Quick Sync Video (hardware embedded in modern Intel CPU)
    • h264_v4l2m2m use V4L2 Linux kernel api to access hardware codecs
    • h264_vaapi use VAAPI which is another abstraction API to access video acceleration hardware (Linux only)
    • h264_videotoolbox use videotoolbox an API to access hardware on macOS

    With proper hardware, each encoder will succeed to encode your decoded gif to mp4.

    You can custom this command to convert gif to mp4 :

    $ ffmpeg -i local-gif.gif -c:v libx264 output.mp4
    

    libx264 is the default encoder which does not use any specific hardware this can be changed to the desired encoder.