Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AAC: Unsupported channel layout "2 channels" #1040

Closed
autogris opened this issue Aug 19, 2024 · 3 comments
Closed

AAC: Unsupported channel layout "2 channels" #1040

autogris opened this issue Aug 19, 2024 · 3 comments

Comments

@autogris
Copy link

Hi, after upgrading ffmpeg to 7.0.2 from 6.x, SSR gives me the following error when trying to produce an mp4 with h264+aac:

[PageRecord::StartPage] Starting page ...
[PageRecord::StartPage] Started page.
[PageRecord::StartOutput] Starting output ...
[PageRecord::StartOutput] Output file: /tmp/video.mp4
[Muxer::Init] Using format mp4 (MP4 (MPEG-4 Part 14)).
[Muxer::AddStream] Using codec libx264 (libx264 H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10).
[VideoEncoder::PrepareStream] Using pixel format nv12.
[libx264 @ 0x27bed500] using SAR=1/1
[libx264 @ 0x27bed500] using cpu capabilities: MMX2 SSE2Fast SSSE3 SSE4.2 AVX FMA3 BMI2 AVX2
[libx264 @ 0x27bed500] profile High, level 3.1, 4:2:0, 8-bit
[libx264 @ 0x27bed500] 264 - core 164 - H.264/MPEG-4 AVC codec - Copyleft 2003-2024 - http://www.videolan.org/x264.html - options: cabac=1 ref=1 deblock=1:0:0 analyse=0x3:0x3 me=dia subme=1 psy=1 psy_rd=1,00:0,00 mixed_ref=0 me_range=16 chroma_me=1 trellis=0 8x8dct=1 cqm=0 deadzone=21,11 fast_pskip=1 chroma_qp_offset=0 threads=8 lookahead_threads=1 sliced_threads=0 nr=0 decimate=1 interlaced=0 bluray_compat=0 constrained_intra=0 bframes=3 b_pyramid=2 b_adapt=1 b_bias=0 direct=1 weightb=1 open_gop=0 weightp=1 keyint=250 keyint_min=25 scenecut=40 intra_refresh=0 rc=crf mbtree=0 crf=23,0 qcomp=0,60 qpmin=0 qpmax=69 qpstep=4 ip_ratio=1,40 pb_ratio=1,30 aq=1:1,00
[Muxer::AddStream] Using codec aac (AAC (Advanced Audio Coding)).
[BaseEncoder::EncoderThread] Encoder thread started.
[AudioEncoder::PrepareStream] Using sample format f32p.
[aac @ 0x27fcfa00] Unsupported channel layout "2 channels"
[aac @ 0x27fcfa00] Qavg: nan
[BaseEncoder::Init] Error: Can't open codec!
[BaseEncoder::~BaseEncoder] Stopping encoder thread ...
[BaseEncoder::EncoderThread] Encoder thread stopped.
[PageRecord::StartOutput] Error: Something went wrong during initialization.

I'm on the latest git commit (4e3ba13)

@ccady
Copy link

ccady commented Aug 28, 2024

I also get this error when I am using the AAC audio codec. I get what I presume is an identical error with the libmp3lame audio encoder.:

[Muxer::AddStream] Using codec libmp3lame (libmp3lame MP3 (MPEG audio layer 3)).
[BaseEncoder::EncoderThread] Encoder thread started.
[AudioEncoder::PrepareStream] Using sample format f32p.
[libmp3lame @ 0x55ec6c612100] Specified channel layout '2 channels' is not supported by the libmp3lame encoder
[libmp3lame @ 0x55ec6c612100] Supported channel layouts:
[libmp3lame @ 0x55ec6c612100] mono
[libmp3lame @ 0x55ec6c612100] stereo
[BaseEncoder::Init] Error: Can't open codec!
[BaseEncoder::~BaseEncoder] Stopping encoder thread ...
[BaseEncoder::EncoderThread] Encoder thread stopped.
[PageRecord::StartOutput] Error: Something went wrong during initialization.

I am using this version in Debian Linux, testing:

SimpleScreenRecorder 0.4.4
Compiled with GCC 14.2.0
Qt: header 5.15.13, lib 5.15.13
libavformat: header 61.1.100, lib 61.1.100
libavcodec: header 61.3.100, lib 61.3.100
libavutil: header 59.8.100, lib 59.8.100
libswscale: header 8.1.100, lib 8.1.100

@flydiscohuebr
Copy link

I replaced this part of the code in the else block with this other part present in the commit #1035

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

if(channels == 1) {
av_channel_layout_from_mask(&codec_context->ch_layout, AV_CH_LAYOUT_MONO);
} else {
av_channel_layout_from_mask(&codec_context->ch_layout, AV_CH_LAYOUT_STEREO);
}

In the end it looked something like this and it worked

#if LIBAVCODEC_VERSION_MAJOR < 61
	codec_context->channels = channels;
	codec_context->channel_layout = (channels == 1)? AV_CH_LAYOUT_MONO : AV_CH_LAYOUT_STEREO;
#else
	if(channels == 1) {
		av_channel_layout_from_mask(&codec_context->ch_layout, AV_CH_LAYOUT_MONO);
	} else {
		av_channel_layout_from_mask(&codec_context->ch_layout, AV_CH_LAYOUT_STEREO);
	}
#endif

@autogris
Copy link
Author

autogris commented Oct 1, 2024

Thanks, I've compiled with your patch and it works!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants