Skip to content

Commit b045b6c

Browse files
authored
add defensive check for avFormatContext_->oformat
1 parent b943504 commit b045b6c

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/torchcodec/_core/Encoder.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -708,6 +708,9 @@ void VideoEncoder::initializeEncoder(
708708
codec,
709709
" not found. To see available codecs, run: ffmpeg -encoders");
710710
} else {
711+
TORCH_CHECK(
712+
avFormatContext_->oformat != nullptr,
713+
"Output format is null, unable to find default codec.");
711714
avCodec = avcodec_find_encoder(avFormatContext_->oformat->video_codec);
712715
TORCH_CHECK(avCodec != nullptr, "Video codec not found");
713716
}

0 commit comments

Comments
 (0)