@@ -468,15 +468,6 @@ void VideoDecoder::addVideoStreamDecoder(
468468 }
469469 TORCH_CHECK (avCodec != nullptr );
470470
471- StreamMetadata& streamMetadata =
472- containerMetadata_.streamMetadatas [streamIndex];
473- if (seekMode_ == SeekMode::approximate &&
474- !streamMetadata.averageFps .has_value ()) {
475- throw std::runtime_error (
476- " Seek mode is approximate, but stream " + std::to_string (streamIndex) +
477- " does not have an average fps in its metadata." );
478- }
479-
480471 StreamInfo& streamInfo = streamInfos_[streamIndex];
481472 streamInfo.streamIndex = streamIndex;
482473 streamInfo.timeBase = formatContext_->streams [streamIndex]->time_base ;
@@ -495,6 +486,15 @@ void VideoDecoder::addVideoStreamDecoder(
495486 .value_or (avCodec));
496487 }
497488
489+ StreamMetadata& streamMetadata =
490+ containerMetadata_.streamMetadatas [streamIndex];
491+ if (seekMode_ == SeekMode::approximate &&
492+ !streamMetadata.averageFps .has_value ()) {
493+ throw std::runtime_error (
494+ " Seek mode is approximate, but stream " + std::to_string (streamIndex) +
495+ " does not have an average fps in its metadata." );
496+ }
497+
498498 AVCodecContext* codecContext = avcodec_alloc_context3 (avCodec);
499499 TORCH_CHECK (codecContext != nullptr );
500500 codecContext->thread_count = videoStreamOptions.ffmpegThreadCount .value_or (0 );
0 commit comments