From ce63c5b057622b2d0acffbb7873bb38ddf11be4a Mon Sep 17 00:00:00 2001 From: pkv Date: Sun, 25 Sep 2022 11:00:32 +0200 Subject: [PATCH] obs-ffmpeg: Update mpegts to channel API change The channel_layout API was overhauled by FFmpeg [1-4]. The previous bitmask channel_layout is replaced by a struct ch_layout which combines the number of channels, a bitmask and other infos. This struct must now be supplied to AVframes since avutil >= 57.24.100 and to AVCodecContext since avcodec 59.24.100 per (1]. This commit provides the required info to obs-ffmpeg-mpegts. [1] Bump minor versions after the channel layout changes FFmpeg/FFmpeg@cdba98b [2] lavc: switch to the new channel layout API FFmpeg/FFmpeg@548aeb9 [3] avutil/channel_layout: Add a new channel layout API FFmpeg/FFmpeg@086a804 [4] avframe: switch to the new channel layout API db6efa18 FFmpeg/FFmpeg@db6efa1 Signed-off-by: pkv --- plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c index 10a0e881e..9e1e5b151 100644 --- a/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c +++ b/plugins/obs-ffmpeg/obs-ffmpeg-mpegts.c @@ -257,12 +257,19 @@ static bool create_audio_stream(struct ffmpeg_output *stream, context->time_base = (AVRational){1, aoi.samples_per_sec}; context->channels = get_audio_channels(aoi.speakers); context->sample_rate = aoi.samples_per_sec; + +#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(59, 24, 100) context->channel_layout = av_get_default_channel_layout(context->channels); //avutil default channel layout for 5 channels is 5.0 ; fix for 4.1 if (aoi.speakers == SPEAKERS_4POINT1) context->channel_layout = av_get_channel_layout("4.1"); +#else + av_channel_layout_default(&context->ch_layout, context->channels); + if (aoi.speakers == SPEAKERS_4POINT1) + context->ch_layout = (AVChannelLayout)AV_CHANNEL_LAYOUT_4POINT1; +#endif context->sample_fmt = AV_SAMPLE_FMT_S16; context->frame_size = data->config.frame_size;