roop
roop copied to clipboard
Hardware accelerated ffmpeg encoders
There is a simple idea: to utilize hardware-accelerated encoders in ffmpeg
parameters if they are supported. Currently, the libx264
encoder is always used for video encoding (even in the next
branch), which is quite slow and produces large video files.
This encoder can be replaced with options such as h264_amf
, h264_vaapi
, h264_nvenc
, etc., depending on what is supported by the hardware, drivers, and ffmpeg
build. This replacement should significantly accelerate encoding time and result in much smaller output file sizes. For example, I tried using h264_nvenc
in the create_video
routine and achieved a tenfold encoding time acceleration and a fivefold size reduction for the final file.
It's important to note that it's not enough to just use the -hwaccel
parameter; certain codecs need to be explicitly specified.
I suggest implementing this as a command line parameter, such as --ffmpeg-encoder=h264_nvenc
.