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);