Skip to content

Commit 649401e

Browse files
committed
Also handle getFramePlayedAtTimestampNoDemux
1 parent 0568482 commit 649401e

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/torchcodec/decoders/_core/VideoDecoder.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -980,7 +980,13 @@ VideoDecoder::DecodedOutput VideoDecoder::getFramePlayedAtTimestampNoDemux(
980980
return seconds >= frameStartTime && seconds < frameEndTime;
981981
});
982982
// Convert the frame to tensor.
983-
auto output = convertAVFrameToDecodedOutput(rawOutput);
983+
auto streamIndex = rawOutput.streamIndex;
984+
auto metadata = containerMetadata_.streams[streamIndex];
985+
auto options = streams_[streamIndex].options;
986+
auto height = options.height.value_or(*metadata.height);
987+
auto width = options.width.value_or(*metadata.width);
988+
auto preAllocatedOutputTensor = makeEmptyHWCTensor(height, width);
989+
auto output = convertAVFrameToDecodedOutput(rawOutput, preAllocatedOutputTensor);
984990
output.frame = MaybePermuteHWC2CHW(output.streamIndex, output.frame);
985991
return output;
986992
}

0 commit comments

Comments
 (0)