Normalize unspecified PCM channel layouts before AAC setup

This commit is contained in:
evgeny committed 2026-10-22 00:03:12 +02:00
1 parent fe313cf8f8
commit 5929bb4028
1 file changed
+5
+5
View File
@@ -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);