File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed
src/torchcodec/decoders/_core Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -546,8 +546,9 @@ void VideoDecoder::scanFileAndUpdateMetadataAndIndex() {
546546 if (scanned_all_streams_) {
547547 return ;
548548 }
549+
550+ UniqueAVPacket packet (av_packet_alloc ());
549551 while (true ) {
550- UniqueAVPacket packet (av_packet_alloc ());
551552 int ffmpegStatus = av_read_frame (formatContext_.get (), packet.get ());
552553 if (ffmpegStatus == AVERROR_EOF) {
553554 break ;
@@ -560,6 +561,7 @@ void VideoDecoder::scanFileAndUpdateMetadataAndIndex() {
560561 int streamIndex = packet->stream_index ;
561562
562563 if (packet->flags & AV_PKT_FLAG_DISCARD) {
564+ av_packet_unref (packet.get ());
563565 continue ;
564566 }
565567 auto & streamMetadata = containerMetadata_.streams [streamIndex];
@@ -578,6 +580,7 @@ void VideoDecoder::scanFileAndUpdateMetadataAndIndex() {
578580 streams_[streamIndex].keyFrames .push_back (frameInfo);
579581 }
580582 streams_[streamIndex].allFrames .push_back (frameInfo);
583+ av_packet_unref (packet.get ());
581584 }
582585 for (size_t streamIndex = 0 ; streamIndex < containerMetadata_.streams .size ();
583586 ++streamIndex) {
You can’t perform that action at this time.
0 commit comments