ffmpeg-python icon indicating copy to clipboard operation
ffmpeg-python copied to clipboard

NVENCODE to speed up encoding.

Open santhoshnumberone opened this issue 6 years ago • 3 comments

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?

santhoshnumberone avatar Oct 31 '19 06:10 santhoshnumberone

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.

scostandache avatar Nov 07 '19 14:11 scostandache

@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.

MenglingD avatar Nov 23 '20 12:11 MenglingD

Poor documentation is quite annoying. This is the first place that I found some basic usage for this library.

Tenglon avatar Sep 19 '22 10:09 Tenglon