ffmpeg: AMD & NVIDIA hardware video encoding (h264, h265)

ffmpeg: AMD & NVIDIA hardware video encoding (h264, h265)

I recently needed to export some video from an Enterprise Video Surveillance system. The system will only export mjpeg avi videos, which are huge files. I ended up using ffmpeg to encode these videos into h.264 mp4 files. I performed the video encoding on a machine with an AMD GPU. This article documents some of the ffmpeg command line switches require to perform hardware video encoding on both NVIDIA and AMD GPUs.

Encode AVI to h.264 Video (Software Encoding)

ffmpeg -i input.avi -c:v libx264 output.mp4

Encode AVI to h.265 Video (Software Encoding)

ffmpeg -i input.avi -c:v libx265 output.mp4

Encode AVI to h.264 Video (AMD GPU Encoding)

ffmpeg -i input.avi -c:v h264_amf output.mp4

Encode AVI to h.265 Video (AMD GPU Encoding)

ffmpeg -i input.avi -c:v hevc_amf output.mp4

Encode AVI to h.264 Video (NVIDIA GPU Encoding)

ffmpeg -i input.avi -c:v h264_nvenc output.mp4

Encode AVI to h.265 Video (NVIDIA GPU Encoding)

ffmpeg -i input.avi -c:v hevc_nvenc output.mp4

6 Replies to “ffmpeg: AMD & NVIDIA hardware video encoding (h264, h265)”

  1. Hi, thanks for the clean and simply laid out article and commands. When using the h264_amf parameter, I get the following error message:

    “DLL amfrt64.dll failed to open
    Error initializing output stream 0:0 – Error while opening encoder for output stream #0:0 – maybe incorrect parameters such as bit_rate, rate, width or height”.

    I’ve got an AMD Radeon HD 5770 card with the latest updated drivers on Windows 10 Build 1909 x64 and my video output from this GPU is just fine. Could you please help? Thanks in advance.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.