Skip to content

Commit

Permalink
Always report mono for one channel
Browse files Browse the repository at this point in the history
  • Loading branch information
bmatherly committed Jul 31, 2024
1 parent 1570747 commit 55fac44
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/modules/avformat/producer_avformat.c
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,9 @@ static mlt_properties find_default_streams(producer_avformat self)
mlt_channel_layout mlt_layout = mlt_channel_independent;
#if HAVE_FFMPEG_CH_LAYOUT
mlt_properties_set_int(meta_media, key, codec_params->ch_layout.nb_channels);
if (av_channel_layout_check(&codec_params->ch_layout)) {
if (codec_params->ch_layout.nb_channels == 1)
mlt_layout = mlt_channel_mono;
else if (av_channel_layout_check(&codec_params->ch_layout)) {
mlt_layout = av_channel_layout_to_mlt(&codec_params->ch_layout);
} else {
AVChannelLayout ch_layout;
Expand All @@ -535,7 +537,9 @@ static mlt_properties find_default_streams(producer_avformat self)
}
#else
mlt_properties_set_int(meta_media, key, codec_params->channels);
if (codec_params->channel_layout == 0)
if (codec_params->channels == 1)
mlt_layout = mlt_channel_mono;
else if (codec_params->channel_layout == 0)
mlt_layout = av_channel_layout_to_mlt(
av_get_default_channel_layout(codec_params->channels));
else
Expand Down Expand Up @@ -3537,7 +3541,9 @@ static int producer_get_audio(mlt_frame frame,
sizeof_sample = sample_bytes(codec_ctx);
#if HAVE_FFMPEG_CH_LAYOUT
*channels = codec_ctx->ch_layout.nb_channels;
if (av_channel_layout_check(&codec_ctx->ch_layout)) {
if (*channels == 1)
mlt_layout = mlt_channel_mono;
else if (av_channel_layout_check(&codec_ctx->ch_layout)) {
mlt_layout = av_channel_layout_to_mlt(&codec_ctx->ch_layout);
} else {
AVChannelLayout ch_layout;
Expand All @@ -3547,7 +3553,9 @@ static int producer_get_audio(mlt_frame frame,
}
#else
*channels = codec_ctx->channels;
if (codec_ctx->channel_layout == 0)
if (*channels == 1)
mlt_layout = mlt_channel_mono;
else if (codec_ctx->channel_layout == 0)
mlt_layout = av_channel_layout_to_mlt(
av_get_default_channel_layout(codec_ctx->channels));
else
Expand Down

0 comments on commit 55fac44

Please sign in to comment.