I am trying to add the hwaccel option of ffmpeg to a script I am working on in Python, based on the moviepy library, by passing the options via the ffmpeg_params
parameter:
from moviepy.editor import VideoFileClip
ASSETS_FOLDER = "./assets/backgrounds/road/"
video_file_name = "12386.mp4"
start_time = 5
end_time = 20
target_file = "output.mp4"
video = VideoFileClip(f"{ASSETS_FOLDER}{video_file_name}")
new = video.subclip(start_time, end_time)
new.fps = 25
new.write_videofile(target_file, ffmpeg_params= ['-hwaccel','cuda'])
The problem is that these ffmpeg_params are added at the end of the ffmpeg command line, so I am getting the following error:
[Errno 22] Invalid argument
MoviePy error: FFMPEG encountered the following error while writing file
./assets/temp/3/cut1.mp4:
b'Option hwaccel (use HW accelerated decoding) cannot be applied to output url
./assets/temp/3/cut1.mp4 -- you are trying to apply an input option to an output file
or vice versa. Move this option before the file it belongs to.\r\nError parsing
options for output file ./assets/temp/3/cut1.mp4.\r\nError opening output files:
Invalid argument\r\n'
Is there another way to use the option with moviepy