NVENCODE to speed up encoding.
I would like to use GPU instead of CPU for encoding a video.
Getting Started with FFmpeg/libav using NVIDIA GPUs
After installing installing ffmpeg and configuring cuda before installing it.
Can i use the regular command here to make use of GPU instead of CPU?
Here's an example of how I do the things:
import ffmpeg
input_args = {
"hwaccel": "nvdec",
"vcodec": "h264_cuvid",
"c:v": "h264_cuvid"
}
output_args = {
"vcodec": "hevc_nvenc",
"c:v": "hevc_nvenc",
"preset": "fast",
"crf": 0,
"b:v": "20M",
"acodec": "copy"
}
(
ffmpeg
.input('Input/my_video.mp4', **input_args)
.output('Output/out.mkv', **output_args)
.run()
)
Of course, this is a very simple example, in which nothing much is done to the input video, but it's running on GPU.
@serbanc94, thanks, your example is very helpful. And how can we find more options supported by input_args(eg, device_id), which isn't descripted in doc of ffmpeg-python.
Poor documentation is quite annoying. This is the first place that I found some basic usage for this library.