bestsource icon indicating copy to clipboard operation
bestsource copied to clipboard

Feature request: hwdevice, fallback to cpu on failure instead of throwing an error

Open Selur opened this issue 1 year ago • 8 comments

hwdevice: The interface to use for hardware decoding. Depends on OS and hardware. On windows d3d11va, cuda and vulkan (H264, HEVC and AV1) are probably the ones most likely to work. Defaults to CPU decoding. Will throw errors for formats where hardware decoding isn't possible.

Would be nice if hwdevice would be more like a preference than a force of the device, so that I set by default for example 'cuda' and if the fails, it would fall back to 'cpu'-decoding and only if that fails to, throw an error.

Thanks!

Selur avatar Sep 07 '24 12:09 Selur

This could cause some unexpected behaviour and make it hard to force hardware decoding in cases where you actually want to make sure you're using hardware decoding and error out otherwise (e.g. when debugging something involving hwdec). IMO this would be better handled with a simple python wrapper function. Alternatively, there could be additional options like cuda-safe to opt in to falling back to cpu decoding, but a wrapper sounds more sensible to me.

arch1t3cht avatar Sep 07 '24 12:09 arch1t3cht

Instead of having to add a 'cuda-safe', 'qsv-save',... option adding an additional parameter i.e. 'fallback: bool, whether to fallback to cpu encoding on error' seems like a better way to go at this.

Sure, one could write a wrapper, but personally I think a solution in the filter itself is to be preferred to allow easier usage.

Selur avatar Sep 07 '24 13:09 Selur

I'm going to say "wrapper function" mostly for this. I suppose for formats where no hw decoder exists for the selected format it could use a fallback to cpu but internally it would literally be the same as a wrapper function.

myrsloik avatar Sep 07 '24 13:09 myrsloik

Sure, the main difference is whether this is implemented once or whether each user has to make sure he uses the wrapper. :) So would be nice if this could be added. :D

Selur avatar Sep 07 '24 13:09 Selur

hwfallback=true maybe, and note that fallback would only be for the case where no hw decoder exists, not the case that the hw decoder shits itself on decode start I'll think about it

myrsloik avatar Sep 07 '24 13:09 myrsloik

Sounds good to me, if the decoder should work and crashes it should crash. If no decode i.e. ProRes, Huffyuv,... exists falling back to cpu sound good.

Selur avatar Sep 07 '24 13:09 Selur

This was more annoying to implement than anticipated. Don't expect it to happen soon.

myrsloik avatar Oct 19 '24 18:10 myrsloik

Thanks for the update.

Selur avatar Oct 19 '24 18:10 Selur

Implemented but untested

myrsloik avatar May 13 '25 19:05 myrsloik