Opened 9 months ago

Closed 8 months ago

#2420 closed defect (fixed)

mencoder: channel layout not supported by encoder

Reported by: ffigs Owned by: beastd
Priority: normal Component: undetermined
Version: HEAD Severity: normal
Keywords: Cc: ffigs
Blocked By: Blocking:
Reproduced by developer: no Analyzed by developer: no

Description

Summary of the bug:

When transcoding audio to certain lavc codecs, mencoder hits an error and quits, e.g.:

[ac3 @ 0x55837f4ac940]Specified channel layout '2 channels' is not supported by the ac3 encoder
[ac3 @ 0x55837f4ac940]Supported channel layouts:
[ac3 @ 0x55837f4ac940]  mono
[ac3 @ 0x55837f4ac940]  stereo
[ac3 @ 0x55837f4ac940]  3.0(back)
[ac3 @ 0x55837f4ac940]  3.0
[ac3 @ 0x55837f4ac940]  quad(side)
[ac3 @ 0x55837f4ac940]  quad
[ac3 @ 0x55837f4ac940]  4.0
[ac3 @ 0x55837f4ac940]  5.0(side)
[ac3 @ 0x55837f4ac940]  5.0
[ac3 @ 0x55837f4ac940]  2 channels (FC+LFE)
[ac3 @ 0x55837f4ac940]  2.1
[ac3 @ 0x55837f4ac940]  4 channels (FL+FR+LFE+BC)
[ac3 @ 0x55837f4ac940]  3.1
[ac3 @ 0x55837f4ac940]  4.1
[ac3 @ 0x55837f4ac940]  5.1(side)
[ac3 @ 0x55837f4ac940]  5.1
Couldn't open codec ac3, br=224.

How to reproduce:

  1. Use ffmpeg to synthesize a test file, which we'll try to re-encode with mencoder:
    $ ffmpeg \
    -f lavfi -i testsrc=duration=10:size=1280x720:rate=30 \
    -f lavfi -i sine=frequency=1000:duration=10 -ac 2 -c:a pcm_s16le \
    vid1.mkv
    
  2. Use mencoder to re-encode the audio track with some lavc codec:
    $ mencoder vid1.mkv -ovc copy -oac lavc -lavcopts acodec=$codec -of lavf -o vid2.mkv
    

The problem codecs are ac3, mp2, and li1mp3lame. flac, wmav1, and wmav2 are not affected and work on my system.

Details

The input codec/container doesn't seem to matter, nor does the actual output audio channel layout, since common layouts such as stereo/mono are affected (also 5.1 for AC3). Re-encoding the video or not also makes no difference. So, there's nothing really significant about the test file. It's 100% correlated with the output codec as far as I can tell.

Issue is not present on older mencoder version r38435 (via RPMFusion repo, statically-linked to ffmpeg 4.4.4).

Could it be due to "2 channels" vs "stereo"?

Fedora 39, tested on latest SVN (r38458) with latest ffmpeg as well as ffmpeg 6.1.1 release. Logs are for an ac3 encode with MPLAYER_VERBOSE=9.

Attachments (3)

logGood (164.6 KB ) - added by ffigs 9 months ago.
Successful ac3 encode with mencoder r38435
logBad (6.6 KB ) - added by ffigs 9 months ago.
Unsuccessful ac3 encode using mencoder r38458
0001-ae-lavc-Generate-a-guessed-AVChannelLayout-based-on-.patch (1014 bytes ) - added by beastd 8 months ago.

Download all attachments as: .zip

Change History (8)

by ffigs, 9 months ago

Attachment: logGood added

Successful ac3 encode with mencoder r38435

by ffigs, 9 months ago

Attachment: logBad added

Unsuccessful ac3 encode using mencoder r38458

comment:1 by beastd, 8 months ago

Status: newopen

Thanks for the report!
I could reproduce.

It's probably related to the adoption of FFmpeg API AVChannelLayout .

I have an idea on how to fix it. Will try it out and if it works, provide a patch for you to test here.

comment:2 by beastd, 8 months ago

Patch attached as attachment:0001-ae-lavc-Generate-a-guessed-AVChannelLayout-based-on-.patch

Could you please try and report if it works for you?

comment:3 by beastd, 8 months ago

I have already committed to MPlayer SVN because I think almost no lavc encoders could work without the fix.

So you could just svn up and r38460 and above should work.

comment:4 by ffigs, 8 months ago

Thanks for getting this sorted so quickly! Fixed for me as well as of r38460.

comment:5 by beastd, 8 months ago

Resolution: fixed
Status: openclosed

You're welcome!

Thanks for reporting back. Closing this as fixed now.

Note: See TracTickets for help on using tickets.