I'm batch-transcoding a library of clips into downscaled editing proxies. If I kick off two hardware transcodes at once, the encoder reliably falls over, so right now I run everything serially: each clip gets fully decoded, encoded, and muxed before the next one starts. It works, but it's slow, and the decode and encode hardware are mostly idle waiting on each other.
A few things I can't pin down from the docs:
- Is there an actual ceiling on how many VTCompressionSession / VTDecompressionSession instances can be live at once, and does it depend on the device, the codec, or the resolution?
- Can I query that ceiling at runtime? I'd rather size my concurrency up front than find it by crashing.
- Decode and encode are separate hardware blocks, so can I safely run a decode session for one clip while the previous clip is still encoding, or does VideoToolbox serialize them anyway?
- When I do go over the limit, what should I be checking so I can back off cleanly? Right now I just get a crash instead of an error I can catch.
Anything that gets me off the fully-serial pipeline would help. Thank you
It's certainly not OK that the device panics in this situation. If possible, I'd ask you to file a FBA with the panic .ips file and also a test Xcode project that can reproduce the panic. If you can do that, please post the FBA number here so we can ensure it's routed promptly to the right team.
https://developer.apple.com/feedback-assistant/
It's very common for iPhones to be transcoding video, so maybe there is something novel about how your code is approaching this that isn't anticipated and handled correctly. So a test project may be vital to help engineers at Apple reproduce the panic and fix the cause.
Returning to the other parts of the question: you wrote that this is batch-transcoding, correct? So I would presume that you're interested in throughput rather than real-time needs. It's valid to operate multiple VTDecompressionSessions and multiple VTCompressionSessions. Each EncodeFrame/DecodeFrame call will block at a back-pressure threshold.