Skip to content

Commit 3aa6c65

Browse files
committed
Address comments
1 parent 7291b83 commit 3aa6c65

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/torchcodec/_core/SingleStreamDecoder.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1178,7 +1178,14 @@ void SingleStreamDecoder::convertAudioAVFrameToFrameOutputOnCPU(
11781178
int desiredSampleRate =
11791179
streamInfo.audioStreamOptions.sampleRate.value_or(sourceSampleRate);
11801180

1181-
int sourceNumChannels = getNumChannels(srcAVFrame);
1181+
int sourceNumChannels = getNumChannels(streamInfo.codecContext);
1182+
TORCH_CHECK(
1183+
sourceNumChannels == getNumChannels(srcAVFrame),
1184+
"The Frame has ",
1185+
getNumChannels(srcAVFrame),
1186+
" channels, expected ",
1187+
sourceNumChannels,
1188+
".");
11821189
int desiredNumChannels =
11831190
streamInfo.audioStreamOptions.numChannels.value_or(sourceNumChannels);
11841191

src/torchcodec/decoders/_audio_decoder.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ class AudioDecoder:
3939
Note that this index is absolute across all media types. If left unspecified, then
4040
the :term:`best stream` is used.
4141
sample_rate (int, optional): The desired output sample rate of the decoded samples.
42-
By default, the samples are returned in their original sample rate.
42+
By default, the sample rate of the source is used.
4343
num_channels (int, optional): The desired number of channels of the decoded samples.
44-
By default, the original number of channels is used.
44+
By default, the number of channels of the source is used.
4545
4646
Attributes:
4747
metadata (AudioStreamMetadata): Metadata of the audio stream.

0 commit comments

Comments
 (0)