Fix Scene Detection frames mismatch causes invalid frame access crashes #927
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Scene Detection currently uses FFmpeg, even when the chunking method used later encodes the video with a VapourSynth script. This leads to a mismatch in the frame count and crashes on the offending chunk. Scene Detection should instead use the same decoding method as Av1an does when encoding chunks in order to avoid this mismatch.
Additionally, when testing this fix I discovered a race condition that fails scene detection when retrieving the frame count in a thread. I don't fully understand why this occurs but moving the resolution of that thread before scene detection starts resolves that race condition.
This issue can be replicated by improperly cutting a lossless clip and using that as the input while specifying a chunking method that generates/uses a VapourSynth script.
As a workaround, users can instead input a VapourSynth script instead of the clip itself and the Scene Detection should perform the same function as this PR.
Thank you,
- Boats M.