How to run ffmpeg with hardware encoding when using –filter_complex to hardcode subtitles?

  Kiến thức lập trình

I’m converting MKV files and hardcoding subtitles into MP4 format. I have over 100 files and want to speed the process up by enabling hardware encoding. I am able to hardware encode without hardcoding the subtitles via –filter_complex but as soon as I apply the filter it errors out.

Here is my command line that works perfectly fine.

ffmpeg -i input.mkv -filter_complex “[0:v:0]subtitles=’input.mkv’:si=0[v]” -map “[v]” -map 0:a:1 -c:a copy -map_chapters -1 “output.mp4”

Here is my command line that works with hardware encoding without –filter_complex

ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mkv -c:v hevc_nvenc -map 0:a:1 -c:a copy -map_chapters -1 “output.mp4”

What I need to do is enable hardware encoding with –filter_complex, So I tried this command

ffmpeg -hwaccel cuda -hwaccel_output_format cuda -i input.mkv -filter_complex “[0:v:0]subtitles=’input.mkv’:si=0[v]” -map “[v]” -c:v hevc_nvenc -map 0:a:1 -c:a copy -map_chapters -1 “output.mp4”

I get this error

Impossible to convert between the formats supported by the filter ‘graph 0 input from stream 0:0’ and the filter ‘auto_scale_0’

LEAVE A COMMENT