Bug#1111314: simplescreenrecorder: audio recording fails with "Unsupported channel layout"

Armin Fuerst <[email protected]>
Newsgroups gmane.linux.debian.devel.multimedia
Message-ID <f1bb1261-fbe3-4acd-ae39-691b548aee8e__24181.9214819529$1782231327$gmane$org@fuerst.priv.at>
I am also affected by this bug, analyzed it using Claude. Below is a 
summary generated by Claude.

Cheers,
Armin




I can confirm this on Debian 13 (trixie) with simplescreenrecorder 
0.4.4-6 and FFmpeg 7.1.1 (libavcodec61).

The failure is not specific to AAC — every strict encoder is affected. 
With MP3 selected, libmp3lame gives a more explicit hint:

   [libmp3lame] Specified channel layout '2 channels' is not supported 
by the libmp3lame encoder
   [libmp3lame] Supported channel layouts: mono, stereo

Root cause: the new-API branch added by 1020-ffmpeg-7.patch sets

   codec_context->ch_layout.nb_channels = channels;
   codec_context->ch_layout.u.mask = (channels == 1) ? AV_CH_LAYOUT_MONO 
: AV_CH_LAYOUT_STEREO;

but leaves ch_layout.order at AV_CHANNEL_ORDER_UNSPEC. The encoders 
therefore see an unnamed "2 channels" layout instead of "stereo" and 
refuse to open.

Upstream already solves this. In src/AV/Output/AudioEncoder.cpp the 
SSR_USE_AV_CHANNEL_LAYOUT branch uses:

   av_channel_layout_default(&codec_context->ch_layout, channels);

This sets order/nb_channels/mask correctly and covers both FFmpeg 7 and 
8 in a single line. The cleanest fix is to make the Debian patch's #else 
branch match upstream instead of assigning the fields by hand.

Regarding the patch already attached to this report: it is functionally 
correct — av_channel_layout_from_mask() also produces a NATIVE-order 
layout, so it does fix the bug. It is just more elaborate than 
necessary; the single av_channel_layout_default() call above would be 
sufficient and matches upstream exactly.

I have verified the upstream code path; the only divergence is the 
version gate (upstream switches to the new API at libavcodec 59.24, the 
Debian patch at major >= 61), which is harmless on trixie.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.