File tree 2 files changed +21
-0
lines changed 2 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -368,6 +368,9 @@ bool FFmpegAudioDecoder::ConfigureDecoder(const AudioDecoderConfig& config) {
368
368
const AVCodec* codec = [&config, this ]() {
369
369
if (config.codec () == AudioCodec::kOpus )
370
370
return avcodec_find_decoder_by_name (" libopus" );
371
+ if (config.codec () == AudioCodec::kMP3 ) {
372
+ return avcodec_find_decoder_by_name (" mp3" );
373
+ }
371
374
return avcodec_find_decoder (codec_context_->codec_id );
372
375
}();
373
376
#else
Original file line number Diff line number Diff line change @@ -246,6 +246,24 @@ bool FFmpegGlue::OpenContext(bool is_local_file) {
246
246
CHECK_NE (container_, container_names::MediaContainerName::kContainerUnknown );
247
247
LogContainer (is_local_file, container_);
248
248
249
+ #if BUILDFLAG(IS_QTWEBENGINE) && BUILDFLAG(USE_SYSTEM_FFMPEG)
250
+ // Sometimes FFmpeg is not aware of the whitelisted codecs and
251
+ // configures streams and demuxers with unsupported codecs/params.
252
+ // Force the correct codecs to avoid problems later.
253
+ // https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#a52f39351b15890ef57cc6ff0ec9ab42d
254
+ // https://ffmpeg.org/doxygen/7.0/structAVFormatContext.html#ae5e087f4623b907517c0f7dd8327387d
255
+
256
+ // Note: don't forget to update FFmpeg[Audio|Video]Decoder::ConfigureDecoder
257
+
258
+ if (strcmp (format_context_->iformat ->name , " mp3" ) == 0 ) {
259
+ const AVCodec* mp3_codec = avcodec_find_decoder_by_name (" mp3" );
260
+ if (mp3_codec) {
261
+ format_context_->audio_codec = mp3_codec;
262
+ } else {
263
+ LOG (ERROR) << " No supported codec for mp3" ;
264
+ }
265
+ }
266
+ #endif
249
267
return true ;
250
268
}
251
269
You can’t perform that action at this time.
0 commit comments