Skip to content

Commit 41ba5bd

Browse files
committed
refactor(UBFFmpegVideoEncoder): Use avcodec_get_supported_config
FFmpeg 7.1 introduces avcodec_get_supported_config to query available sample formats. It basically copies over sample_fmts, but doing so directly is deprecated.
1 parent 31aad35 commit 41ba5bd

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

src/podcast/ffmpeg/UBFFmpegVideoEncoder.cpp

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -448,7 +448,19 @@ bool UBFFmpegVideoEncoder::init()
448448
}
449449

450450
c->bit_rate = 96000;
451-
c->sample_fmt = audioCodec->sample_fmts ? audioCodec->sample_fmts[0] : AV_SAMPLE_FMT_FLTP;// FLTP by default for AAC
451+
452+
const AVSampleFormat* sample_fmts;
453+
#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(61, 19, 100)
454+
sample_fmts = audioCodec->sample_fmts;
455+
#else
456+
int err = avcodec_get_supported_config(nullptr, audioCodec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void**)&sample_fmts, nullptr);
457+
if (err) {
458+
setLastErrorMessage("Could not get supported sample formats");
459+
return false;
460+
}
461+
#endif
462+
c->sample_fmt = sample_fmts ? sample_fmts[0] : AV_SAMPLE_FMT_FLTP;// FLTP by default for AAC
463+
452464
c->sample_rate = mAudioSampleRate;
453465

454466
#if LIBAVUTIL_VERSION_INT < AV_VERSION_INT(57, 25, 100)

0 commit comments

Comments
 (0)