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.

 

CUDA Deinterlace

$ ffmpeg -hwaccel cuvid -c:v mpeg2_cuvid -i INPUT -vf hwdownload,format=nv12,yadif,hwupload_cuda -preset fast -acodec aac -ar 44100 -ac 2 -b:a 96k -vcodec h264_nvenc -b:v 2500k -maxrate 3000k -bufsize 5000k -g 150 -qmin 1 -qmax 50 -f flv OUTPUT

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

 

Check all available options for encoder h264_nvenc

Very usable function if you need to know all available options supported by specific encoder or decoder:

$ ffmpeg -h encoder=h264_nvenc

Example output for mpeg2_cuvid decoder:

mpeg2_cuvid decoder options

How To Choose GPU To Be Used In FFmpeg

 

Summary
FFmpeg GPU Transcoding Examples
Article Name
FFmpeg GPU Transcoding Examples
Description
FFmpeg GPU Transcoding Examples
Author
Publisher Name
ARSTECH
Publisher Logo

arstech

Leave a Reply

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