I want to use ffmpeg to accelerate video encode and decode with an NVIDIA GPU.
From NVIDIA's website:
NVIDIA GPUs contain one or more hardware-based decoder and encoder(s) (separate from the CUDA cores) which provides fully-accelerated hardware-based video decoding and encoding for several popular codecs. With decoding/encoding offloaded, the graphics engine and the CPU are free for other operations.
My question is: can I use CUDA cores to encode and decode video, maybe faster?
FFmpeg with NVIDIA GPU acceleration is supported on all Windows platforms, with compilation through Microsoft Visual Studio 2013 SP2 and above, and MinGW. Depending upon the Visual Studio Version and CUDA SDK version used, the paths specified may have to be changed accordingly.
GPU Acceleration reduces the stress that video editing software apply on CPU and improve the speed and efficiency of these software. Enabling GPU acceleration for video rendering, playback saves you from waiting and improve the playback quality.
FFmpeg provides a subsystem for hardware acceleration, which includes NVIDIA: https://trac.ffmpeg.org/wiki/HWAccelIntro
In order to enable support for GPU-assisted encoding with an NVIDIA GPU, you need:
--enable-nvenc
(default if the drivers are detected while configuring)Quick use on supported GPU:
CUDA
ffmpeg -hwaccel cuda -i input output
CUVID
ffmpeg -c:v h264_cuvid -i input output
Full hardware transcode with NVDEC and NVENC:
ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input -c:v h264_nvenc -preset slow output
If ffmpeg was compiled with support for libnpp, it can be used to insert a GPU based scaler into the chain:
ffmpeg -hwaccel_device 0 -hwaccel cuda -i input -vf scale_npp=-1:720 -c:v h264_nvenc -preset slow output.mkv
Source: https://trac.ffmpeg.org/wiki/HWAccelIntro
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With