Opened 14 months ago
Last modified 13 months ago
#11619 new defect
"libopus" downmix (5.1 -> 2ch) unintended volume clipping
| Reported by: | Marco | Owned by: | |
|---|---|---|---|
| Priority: | normal | Component: | avcodec |
| Version: | 7.1 | Keywords: | libopus |
| Cc: | MasterQuestionable | Blocked By: | |
| Blocking: | Reproduced by developer: | no | |
| Analyzed by developer: | yes |
Description (last modified by )
(I'm using version 7.1.1, the one shipped with Fedora 42)
When downmixing a 5.1 surround track from a film (any film actually) to a stereo 2.0 opus track, the output stereo track seems to be clipping when opened with Tenacity (fork of Audacity).
This is the command I used to convert the 5.1 track to 2.0 opus:
ffmpeg -i audio.mka -c:a libopus -b:a 128k -ac 2 audio.opus
I also tried the following command:
ffmpeg -i audio.mka -ac 2 audio.wav
Comparing the output of both commands in Tenacity, I notice a volume increase in the OPUS track compared to the WAV one, and that makes the volume clip in many parts.
Is there something I'm misunderstanding? The outputs should look similar, they are not.
Attachments (1)
Change History (7)
by , 14 months ago
| Attachment: | screenshot.webp added |
|---|
comment:1 by , 14 months ago
| Description: | modified (diff) |
|---|
comment:2 by , 14 months ago
| Analyzed by developer: | set |
|---|---|
| Cc: | added |
| Component: | undetermined → avcodec |
| Summary: | OPUS downmix volume clipping → "libopus" downmix (5.1 -> 2ch) unintended volume clipping |
comment:3 by , 14 months ago
Thank you for the reply.
Sure, first downmixing to WAV and then converting WAV to OPUS does the job, but I would like to downmix directly to OPUS, and that sounds like an issue since it should give the same output as WAV.
Tried your command and it outputs many errors, the first lines of error are:
[Parsed_channelmap_0 @ 0x7f4a000047c0] input channel 'DL' not available from input layout '5.1(side)' [Parsed_channelmap_0 @ 0x7f4a000047c0] input channel 'DR' not available from input layout '5.1(side)'
comment:4 by , 14 months ago
͏ Perhaps try other channel descriptions?
͏ Per:
͏ https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg#comment2439568_1410620
͏ https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg#1663861
͏ The "channelmap" is just copied from documentation without actual change.
͏ Maybe itself invalid..? ("DL" "DR" be error?)
͏ [ ^ Probably just bad example. ]
͏ See also: https://ffmpeg.org/ffmpeg-utils.html#Channel-Layout
͏ I generally use Mono directly and not bothering these peculiar layouts.
͏ (arrange remix explicitly on need)
comment:5 by , 14 months ago
Although am grateful for the tips, I don't want a workaround... I just would like to understand why there are 2 different outputs when using a format compared to another.
comment:6 by , 13 months ago
͏ FFmpeg tried to use "libopus" 's handling for channel remix.
͏ And "libopus" botched the job.
͏ Some codecs have internal extra conversion capability.
͏ Which FFmpeg may attempt to use.
͏ .
͏ E.g.
͏ "libwebp", when inputting unmatching color format; may warn:
͏ |*| Using libwebp for RGB-to-YUV conversion. You may want to consider passing in YUV instead for lossy encoding.
͏ |*| Using libwebp for YUV-to-RGB conversion. You may want to consider passing in RGB instead for lossless encoding.




͏ Seems "libopus" handled the downmixing wrong..?
͏ Try feeding the already-downmixed version?
͏ E.g.
ffmpeg -v debug -hide_banner -nostdin -nostats -i "audio.mka" -af "channelmap=DL-FL|DR-FR" -c:a libopus -b:a 128k "audio.opus"͏ Related:
͏ https://ffmpeg.org/ffmpeg.html#Audio-Options
͏ https://ffmpeg.org/ffmpeg-filters.html#channelmap
͏ https://superuser.com/questions/852400/properly-downmix-5-1-to-stereo-using-ffmpeg#1410620
͏ Off-Topic:
͏ WebP (lossy VP8) is not WebP Lossless.
͏ The latter suits the context far better.