Opened 10 years ago
Last modified 10 years ago
#4160 new defect
problem encoding opus file with unusual channel mask
Reported by: | Robin | Owned by: | |
---|---|---|---|
Priority: | normal | Component: | undetermined |
Version: | 2.5 | Keywords: | |
Cc: | Blocked By: | ||
Blocking: | Reproduced by developer: | no | |
Analyzed by developer: | no |
Description
Summary of the bug: trying to encode opus audio file with unusual channel mask (for example FL+FR+BL) generates an error.
How to reproduce: ffmpeg -i 3flfrbl.wav 3flfrbl.opus
% ffmpeg -i 3flfrbl.wav 3flfrbl.opus ffmpeg version 2.5 built on December 3rd 2014
Attachments (1)
Change History (11)
by , 10 years ago
Attachment: | 3flfrbl.zip added |
---|
comment:1 by , 10 years ago
output:
Input #0, wav, from 'C:\Music\3flfrbl.wav':
Duration: 00:00:10.00, bitrate: 2304 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 3 channels
(FL+FR+BL), s16, 2304 kb/s
[auto-inserted resampler 0 @ 0000000002a82b00] [SWR @ 0000000002a73d40] Input ch
annel layout '3 channels (FL+FR+BL)' is not supported
[auto-inserted resampler 0 @ 0000000002a82b00] Failed to configure output pad on
auto-inserted resampler 0
Error opening filters!
comment:2 by , 10 years ago
Keywords: | opus encode multichannel channel mask removed |
---|---|
Priority: | important → normal |
Please test current FFmpeg git head before reporting an issue here and please provide the failing command line together with the uncut console output to make this a valid ticket.
comment:3 by , 10 years ago
The build is 2 days old, it was git head 2 days ago.
I can also repro with version 2.3, so it looks like this problem has been there for some time.
Full command line + output:
C:\Music>ffmpeg.exe -i 3flfrbl.wav 3flfrbl.opus
ffmpeg version N-68199-g5fe026f Copyright (c) 2000-2014 the FFmpeg developers
built on Dec 3 2014 23:57:35 with gcc 4.9.2 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-av
isynth --enable-bzlib --enable-fontconfig --enable-frei0r --enable-gnutls --enab
le-iconv --enable-libass --enable-libbluray --enable-libbs2b --enable-libcaca --
enable-libfreetype --enable-libgme --enable-libgsm --enable-libilbc --enable-lib
modplug --enable-libmp3lame --enable-libopencore-amrnb --enable-libopencore-amrw
b --enable-libopenjpeg --enable-libopus --enable-librtmp --enable-libschroedinge
r --enable-libsoxr --enable-libspeex --enable-libtheora --enable-libtwolame --en
able-libvidstab --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis
--enable-libvpx --enable-libwavpack --enable-libwebp --enable-libx264 --enable-
libx265 --enable-libxavs --enable-libxvid --enable-decklink --enable-zlib
libavutil 54. 15.100 / 54. 15.100
libavcodec 56. 13.100 / 56. 13.100
libavformat 56. 15.102 / 56. 15.102
libavdevice 56. 3.100 / 56. 3.100
libavfilter 5. 2.103 / 5. 2.103
libswscale 3. 1.101 / 3. 1.101
libswresample 1. 1.100 / 1. 1.100
libpostproc 53. 3.100 / 53. 3.100
Input #0, wav, from '3flfrbl.wav':
Duration: 00:00:10.00, bitrate: 2304 kb/s
Stream #0:0: Audio: pcm_s16le ([1][0][0][0] / 0x0001), 48000 Hz, 3 channels
(FL+FR+BL), s16, 2304 kb/s
[auto-inserted resampler 0 @ 0000000002bdcb40] [SWR @ 0000000002b77d40] Input ch
annel layout '3 channels (FL+FR+BL)' is not supported
[auto-inserted resampler 0 @ 0000000002bdcb40] Failed to configure output pad on
auto-inserted resampler 0
Error opening filters!
comment:4 by , 10 years ago
I suspect Opus does not support this channel layout: it only support L-C-R afaict. Do you have any other information?
comment:5 by , 10 years ago
One could encode this as channel mapping family 1 with 4 channels, and use the channel mapping table to map the BR channel to silence (so it would not need to be encoded or decoded).
comment:6 by , 10 years ago
As in the following command?
$ ffmpeg -i 3flfrbl.wav -f s16le -channel_layout BR -ar 48k -i /dev/zero -filter_complex amerge out.opus
comment:7 by , 10 years ago
There are several issues at work here.
First, and this is not directly related to libopus, your channel layout is so strange that FFmpeg (more precisely libswresample) does not know what to do with it. I am not sure if this would be something that can be “fixed”.
Second, the format for the header does not allow to express the whole range of channel layouts. This is the same for both Opus-in-Ogg and Matroska: only the standard Vorbis channel layouts can be expressed. In other words, you can not express FL+FR+BL in an Opus file, you can only express it as FL+FR+BL+BR (quad) with a BR channel that happens to be visibly silent. The decoder does not make any effort to remove the silent channel or even notify that it is silent.
Third, because of the previous reason, the libopus mapping in FFmpeg does not make extra efforts to allow strange channel layout mappings.
The way I see it, there are two enhancements that can be added to FFmpeg:
- On the Opus decoder, add an option to remove silent channels from the output.
- On the libopus encoder, make it possible to encode strange channel layouts by specifying the mapping more or less by hand.
(Unfortunately, it seems that libopus is not subtle enough to detect when an input stereo stream has actually two identical channels.)
Also, it seems there is an actual bug that makes libavfilter to prefer FL+FR+BL→6.1 over FL+FR+BR→quad because the BL+BR→SL+SR remapping counts as 2 remapped channels while BL counts only as one preserved channel. This looks like an easy fix.
comment:8 by , 10 years ago
This file was created on purpose with an unusual channel mask to see how opus encoder would react.
Using FFmpeg, while most non-destructive formats such as .caf, .aiff, .wav, .flac store the data and channel mask properly, .aac and .ogg store the 3 channels "as is", assuming FL+FR+FC (which is okay since I guess thoses formats don't have a way to store channel mask).
FFmpeg should do the same for .opus, instead of just failing with an error.
comment:9 by , 10 years ago
I do not agree. Silently discarding some user data based on random guesses is never a good behaviour. This was done in libvorbis before channel layouts were handled properly, and changing the behaviour would break old scripts, but newer code does not suffer from this kind of compatibility burden.
3flfrbl.wav (3 channels file with FL+FR+BL channel mask)