Skip to content

Conversation

@NicolasHug
Copy link
Contributor

@NicolasHug NicolasHug commented Mar 21, 2025

This PR is based on #584 and includes changes from there.

This PR fixes the following bug:

RuntimeError: Error in swr_convert: Success

which we hit on

https://github.com/pytorch/torchcodec/blob/4d894d55075eb1625a1443c54767bc92c31bc286/src/torchcodec/decoders/_core/VideoDecoder.cpp#L1484-L1487

In fact, numConvertedSamples can be 0 and this can be valid: if the input frames has very few samples, and if we're downsampling by a great factor, then swresample would buffer all the samples and just wait for the next samples to output anything. We thus allow an output converted frame to have zero samples. It's up to the caller to handle that case properly (our callers do natively handle this).

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Meta Open Source bot. label Mar 21, 2025
@NicolasHug NicolasHug changed the title Downsample Fix bug when downsampling by a great factor (empty output frame) Mar 21, 2025
@NicolasHug NicolasHug marked this pull request as ready for review March 21, 2025 10:06
@NicolasHug NicolasHug merged commit 901e5d5 into meta-pytorch:main Mar 21, 2025
46 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Meta Open Source bot.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants