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.