@@ -68,7 +68,8 @@ const int* getSupportedSampleRates(const AVCodec& avCodec) {
6868 reinterpret_cast <const void **>(&supportedSampleRates),
6969 &numSampleRates);
7070 if (ret < 0 || supportedSampleRates == nullptr ) {
71- TORCH_CHECK (false , " Couldn't get supported sample rates from encoder." );
71+ // Return nullptr to skip validation in validateSampleRate.
72+ return nullptr ;
7273 }
7374#else
7475 supportedSampleRates = avCodec.supported_samplerates ;
@@ -88,7 +89,9 @@ const AVSampleFormat* getSupportedOutputSampleFormats(const AVCodec& avCodec) {
8889 reinterpret_cast <const void **>(&supportedSampleFormats),
8990 &numSampleFormats);
9091 if (ret < 0 || supportedSampleFormats == nullptr ) {
91- TORCH_CHECK (false , " Couldn't get supported sample formats from encoder." );
92+ // Return nullptr to use default output format in
93+ // findBestOutputSampleFormat.
94+ return nullptr ;
9295 }
9396#else
9497 supportedSampleFormats = avCodec.sample_fmts ;
@@ -161,10 +164,11 @@ void validateNumChannels(const AVCodec& avCodec, int numChannels) {
161164 reinterpret_cast <const void **>(&supported_layouts),
162165 &num_layouts);
163166 if (ret < 0 || supported_layouts == nullptr ) {
164- TORCH_CHECK (false , " Couldn't get supported channel layouts from encoder." );
167+ // If we can't validate, we must assume it'll be fine. If not, FFmpeg will
168+ // eventually raise.
165169 return ;
166170 }
167- for (int i = 0 ; supported_layouts[i]. nb_channels != 0 ; ++i) {
171+ for (int i = 0 ; i < num_layouts ; ++i) {
168172 if (i > 0 ) {
169173 supportedNumChannels << " , " ;
170174 }
0 commit comments