From 5929bb4028d122a2ecfed28d2a3949673ce76a73 Mon Sep 17 00:00:00 2001 From: evgeny Date: Thu, 22 Oct 2026 00:03:12 +0200 Subject: [PATCH] Normalize unspecified PCM channel layouts before AAC setup --- src/video/video.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/video/video.c b/src/video/video.c index 6d893bf6..29e06f4c 100644 --- a/src/video/video.c +++ b/src/video/video.c @@ -526,6 +526,11 @@ static int vc_open_audio(struct vc_ctx* ctx) { struct vc_stream* stream = &ctx->audio; AVCodecContext* decoder = stream->decoder; if (decoder->sample_rate <= 0 || decoder->ch_layout.nb_channels <= 0) return AVERROR_INVALIDDATA; + if (decoder->ch_layout.order == AV_CHANNEL_ORDER_UNSPEC) { + int channels = decoder->ch_layout.nb_channels; + av_channel_layout_default(&decoder->ch_layout, channels); + DEBUG_INFO(DEBUG_CATEGORY_VIDEO, "video audio uses default layout for %d unspecified channels", channels); + } const AVCodec* codec = avcodec_find_encoder(AV_CODEC_ID_AAC); if (!codec) return AVERROR_ENCODER_NOT_FOUND; stream->encoder = avcodec_alloc_context3(codec);