FFmpeg GPU Transcoding Examples

FFmpeg GPU Transcoding Examples

For using FFmpeg hardware acceleration you need compile FFmpeg with NVIDIA NVENC support. How To Compile FFmpeg With NVENC H264 Hardware Encoder.

Here is some examples how to use NVENC encoder.

Basic FFmpeg GPU transcoding. Decoding part using CPU encoding. Encoding using h264 NVENC video encoder:

$ ffmpeg -i INPUT -vcodec h264_nvenc -b:v 5M -acodec copy OUTPUT

Full hardware transcoding with using CUVID and NVENC:

$ ffmpeg -hwaccel cuvid -c:v h264_cuvid -i INPUT -vcodec h264_nvenc -preset slow OUTPUT

$ ffmpeg -hwaccel cuvid -c:v h264_cuvid -i INPUT -vcodec h264_nvenc -b:v 5M OUTPUT

FFmpeg resize using CUDA scale (filter scale_cuda is GPU accelerated video resizer ), full hardware transcoding example:

$ ffmpeg -hwaccel cuvid -c:v h264_cuvid -i INPUT -vf scale_cuda=-1:720 -vcodec h264_nvenc -acodec copy OUTPUT

scale_cuda=-1:720 means keep the same aspect ratio and match the other argument.

Resize with NVIDIA video decoder:

$ ffmpeg -c:v h264_cuvid -hwaccel nvdec -resize 1280x720 -i INPUT -vcodec h264_nvenc -b:v 5M -acodec copy OUTPUT


Leave a Reply

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