We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 7cb2271 commit ee1c7b7Copy full SHA for ee1c7b7
src/torchcodec/decoders/_core/VideoDecoder.cpp
@@ -1468,6 +1468,9 @@ UniqueAVFrame VideoDecoder::convertAudioAVFrameSampleFormatAndSampleRate(
1468
// samples if sample rate conversion is needed. It will buffer the last few
1469
// ones because those require future samples. That's also why we reset
1470
// nb_samples after the call to `swr_convert()`.
1471
+ // We could also use `swr_get_out_samples()` to determine the number of
1472
+ // output samples, but empirically `av_rescale_rnd()` seems to provide a
1473
+ // tighter bound.
1474
convertedAVFrame->nb_samples = av_rescale_rnd(
1475
swr_get_delay(streamInfo.swrContext.get(), sourceSampleRate) +
1476
srcAVFrame->nb_samples,
0 commit comments