stashapp / stash

An organizer for your porn, written in Go. Documentation: https://docs.stashapp.cc
https://stashapp.cc/
GNU Affero General Public License v3.0
8.45k stars 749 forks source link

Fix hwCanFullHWTranscode not detecting no filter errors #4934

Closed NodudeWasTaken closed 3 weeks ago

NodudeWasTaken commented 3 weeks ago

A discord user experienced an error where full hardware transcoding didnt work without a filter (which wasn't tested, we always used a scale filter before). This patch passes the requested resolution from the current transcode down to the tester, such that we test it with a filter if it needs one, or without a filter if it doesnt.

Note that the specific issue was:

ffmpeg error when running command <E:\stash\stash windows\ffmpeg.exe -hide_banner -v error -hwaccel_device 0 -hwaccel cuda -hwaccel_output_format cuda -extra_hw_frames 5 -i \path to movies\movies.mkv -c:v h264_nvenc -rc vbr -cq 15 -movflags frag_keyframe+empty_moov -ac 2 -f mp4 pipe:>: [h264_nvenc @ 0000022c1947be40] Provided device doesn't support required NVENC features

[vost#0:0/h264_nvenc @ 0000022c1947bb80] Error while opening encoder - maybe incorrect parameters such as bit_rate, rate, width or height.

Error while filtering: Function not implemented

[out#0/mp4 @ 0000022c19479580] Nothing was written into output file, because at least one of its streams received no packets.

Which usually indicates a driver/ffmpeg incompatibility, but nevertheless we shouldn't error out because of it. It could also indicate 10 bit input file-hell, which is a rabbit hole of its own (which we could handle with scale_cuda=format=nv12 on some versions of ffmpeg, or simply fall back on no accelerated decode)