File tree Expand file tree Collapse file tree 1 file changed +9
-1
lines changed
src/torchcodec/decoders/_core Expand file tree Collapse file tree 1 file changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -161,7 +161,15 @@ void VideoDecoder::initializeDecoder() {
161161 } else if (avStream->codecpar ->codec_type == AVMEDIA_TYPE_AUDIO) {
162162 AVSampleFormat format =
163163 static_cast <AVSampleFormat>(avStream->codecpar ->format );
164- streamMetadata.sampleFormat = av_get_sample_fmt_name (format);
164+
165+ // If the AVSampleFormat is not recognized, we get back nullptr. We have
166+ // to make sure we don't initialize a std::string with nullptr. There's
167+ // nothing to do on the else branch because we're already using an
168+ // optional; it'll just remain empty.
169+ const char * rawSampleFormat = av_get_sample_fmt_name (format);
170+ if (rawSampleFormat != nullptr ) {
171+ streamMetadata.sampleFormat = std::string (rawSampleFormat);
172+ }
165173 containerMetadata_.numAudioStreams ++;
166174 }
167175
You can’t perform that action at this time.
0 commit comments