Here we can find a set of commands to use in video conversion with ffmpeg and common configurations (resolution, bitrate, encoding, etc), some custom commands to transcode using cuda and AMD AMF
1. h264_cuvid -> Nvidia CUVID H264 decoder (codec h264)
2. hevc_cuvid -> Nvidia CUVID HEVC decoder (codec hevc)
3. av1_cuvid -> Nvidia CUVID AV1 decoder (codec av1)
4. mjpeg_cuvid -> Nvidia CUVID MJPEG decoder (codec mjpeg)
5. mpeg1_cuvid -> Nvidia CUVID MPEG1VIDEO decoder (codec mpeg1video)
6. mpeg2_cuvid -> Nvidia CUVID MPEG2VIDEO decoder (codec mpeg2video)
7. mpeg4_cuvid -> Nvidia CUVID MPEG4 decoder (codec mpeg4)
8. vc1_cuvid -> Nvidia CUVID VC1 decoder (codec vc1)
9. vp8_cuvid -> Nvidia CUVID VP8 decoder (codec vp8)
10. vp9_cuvid -> Nvidia CUVID VP9 decoder (codec vp9)
1. h264_nvenc
2. hevc_nvenc
3. libsvtav1 -> AV1 (SVT-AV1 Encoder and Decoder)
1. h264_amf
2. hevc_amf
1. libsvtav1 -> AV1 (SVT-AV1 Encoder and Decoder) No GPU support
#########################################################################
-c:v
-> To inidicate codec of the video track-c:a copy
-> To copy audio from source-vf scale=1280:720
-> To resize the video to new resolution-vf scale_cuda=1280:720
-> To resize with CUDA-hwaccel cuvid
-> Inidicates Hardware acceleration to use (cuda | cuvid)-hwaccel_output_format cuvid
-> Inidicates acceleration mode to use (cuda | cuvid)-noautorotate
-> Prevents from auto rotate, sometimes ffmpeg rotate portrait videos
#########################################################################
This uses encoder h264 for video, and copy audio from metadata, uses -noautorotate in case is a portrait video
ffmpeg -noautorotate -i input.mp4 -c:a copy -c:v h264 output.mp4
This uses AMD custom encoder, only for AMD CPUs, can accelerate up to 2x:
ffmpeg -noautorotate -i input.mp4 -c:a copy -c:v h264 output.mp4
Resize video with CPU and filter -vf scale=1280:720
:
ffmpeg -noautorotate -i input.mp4 -vf scale=1280:720 -c:a copy -c:v h264 output.mp4
Transcode using CUDA, with encoder h264_nvenc
:
ffmpeg -noautorotate -y -vsync 0 -hwaccel cuvid -hwaccel_output_format cuvid -i input.mp4 -c:a copy -c:v h264_nvenc output.mp4
Transcode using CUDA, using decoder cuda hevc_cuvid
for input stream video, can accelerate 25% the process:
ffmpeg -noautorotate -y -vsync 0 -hwaccel cuvid -hwaccel_output_format cuvid -c:v hevc_cuvid -i input.mp4 -c:a copy -c:v hevc_nvenc output.mp4
Resize video using CUDA, using filter -vf scale_cuda=1280:720
for input stream video:
ffmpeg -y -vsync 0 -hwaccel cuvid -c:v hevc_cuvid -i input.mp4 -vf scale_cuda=1280:720 -c:a copy -c:v hevc_nvenc output.mp4
Decode using CUDA and encode using CPU for the new AV1 codec, decoder cuda hevc_cuvid
, and libsvtav1
for encoding (more about AV1):
ffmpeg -y -vsync 0 -noautorotate -y -vsync 0 -hwaccel cuvid -hwaccel_output_format cuvid -c:v hevc_cuvid -i input.mp4 -c:a copy -c:v libsvtav1 output.mp4