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.44k stars 749 forks source link

Add apple encoder and fix extra_hw_frames bug #4986

Closed NodudeWasTaken closed 1 week ago

NodudeWasTaken commented 1 week ago

A discord user complained that the decoder was bugging out, i suspected this was due to extra_hw_frames, jellyfin fixed this by switching from nv12 to yuv420p which disables passthrough. Jellyfin also adds -threads 1 to cuda to save vram.

Additionally adds the apple encoder for hardware acceleration and brings the requisite fixes. Like scale_vt lacking dimension adjustments, so we retrofitted the intel hack to calculate the dimensions and used it for apple too. It also lacks a format switcher, so no 10bit fixes for it. It also has a higher min resolution than anything we've seen yet, so upped the test resolution.

The only note is that given the apple encoders nature, it really sucks at startup, and given HLS's current tendency to start and stop, it makes the video look like crap. It technically works, but i dont know that we should keep it.

Last time i fixed a bug that caused using no filter to error out because of the pixel format, so now we can add a format switcher if available.

Closes https://github.com/stashapp/stash/issues/4945

kermieisinthehouse commented 1 week ago

On this branch, I receive this error while playing any avi file under cuda:

[transcode] ffmpeg error when running command </usr/bin/ffmpeg -hide_banner -v error -hwaccel_device 0 -threads 1 -hwaccel cuda -hwaccel_output_format cuda -i video.avi -c:v h264_nvenc -rc vbr -cq 15 -movflags frag_keyframe+empty_moov -ac 2 -f mp4 pipe:>: [mpeg4 @ 0x56289828cf00] No decoder surfaces left
Error while decoding stream #0:0: Cannot allocate memory
[mpeg4 @ 0x56289828cf00] No decoder surfaces left
Error while decoding stream #0:0: Cannot allocate memory
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0
NodudeWasTaken commented 1 week ago

On this branch, I receive this error while playing any avi file under cuda:

[transcode] ffmpeg error when running command </usr/bin/ffmpeg -hide_banner -v error -hwaccel_device 0 -threads 1 -hwaccel cuda -hwaccel_output_format cuda -i video.avi -c:v h264_nvenc -rc vbr -cq 15 -movflags frag_keyframe+empty_moov -ac 2 -f mp4 pipe:>: [mpeg4 @ 0x56289828cf00] No decoder surfaces left
Error while decoding stream #0:0: Cannot allocate memory
[mpeg4 @ 0x56289828cf00] No decoder surfaces left
Error while decoding stream #0:0: Cannot allocate memory
Impossible to convert between the formats supported by the filter 'Parsed_null_0' and the filter 'auto_scaler_0'
Error reinitializing filters!
Failed to inject frame into filter network: Function not implemented
Error while processing the decoded data for stream #0:0

Please check if thats fixed now. As a side note this seems to be a ffmpeg version 4 issue