Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/torchcodec/decoders/_core/VideoDecoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,15 @@ void VideoDecoder::initializeDecoder() {
} else if (avStream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO) {
AVSampleFormat format =
static_cast<AVSampleFormat>(avStream->codecpar->format);
streamMetadata.sampleFormat = av_get_sample_fmt_name(format);

// If the AVSampleFormat is not recognized, we get back nullptr. We have
// to make sure we don't initialize a std::string with nullptr. There's
// nothing to do on the else branch because we're already using an
// optional; it'll just remain empty.
const char* rawSampleFormat = av_get_sample_fmt_name(format);
if (rawSampleFormat != nullptr) {
streamMetadata.sampleFormat = std::string(rawSampleFormat);
}
containerMetadata_.numAudioStreams++;
}

Expand Down
Loading