Skip to main content

FFmpeg

FFmpeg is a great tool for audio and video operations.

Find your video codec (libx264 will always be available as a CPU-accelerated codec):

ffmpeg -codecs | grep -E "h264"

For example:

DEV.LS h264                 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10 (decoders: h264 h264_v4l2m2m libopenh264 ) (encoders: libx264 libx264rgb libopenh264 h264_v4l2m2m h264_vaapi )

Here we can see that the available encoders for my system are: libx264 libx264rgb libopenh264 h264_vaapi.

libx264 and libx264rgb are CPU accelerated, but will usually result in the highest quality.

h264_v4l2m2m and h264_vaapi are hardware accelerated, but will need a higher bitrate to achieve the quality that software encoders can.

Changing the framerate

(replace 30 with whichever framerate)

VA-API:

ffmpeg -hwaccel vaapi -r 30 -i example_video.mp4 -vcodec h264_vaapi -vf 'format=nv12,hwupload' -q 20 example_output.mp4

x264:

ffmpeg -r 30 -i example_video.mp4 -vcodec libx264 -crf 20 example_output.mp4