Apparently the -mapping_family option for the libopus encoder,
introduced by commit 3794187, breaks encoding of audio with more
than 2 channels. Encoding a 5.1 audio stream without any further
options errors out, because channel layout 5.1(side) is supposedly
invalid. OTOH, opusenc has no problem encoding such streams.

$ ffmpeg -y -i sample.flac sample.opus
ffmpeg version N-81293-g81fcd91 Copyright (c) 2000-2016 the FFmpeg developers
   built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --extra-cflags='-march=native' --enable-gpl --enable-nonfree --enable-libfdk-aac --disable-runtime-cpudetect --enable-libx264 --enable-libvorbis --enable-gnutls --enable-opengl --enable-libopus --enable-libfreetype --enable-libfontconfig --enable-libfribidi --enable-libsoxr
   libavutil      55. 28.100 / 55. 28.100
   libavcodec     57. 51.100 / 57. 51.100
   libavformat    57. 46.100 / 57. 46.100
   libavdevice    57.  0.102 / 57.  0.102
   libavfilter     6. 50.100 /  6. 50.100
   libswscale      4.  1.100 /  4.  1.100
   libswresample   2.  1.100 /  2.  1.100
   libpostproc    54.  0.100 / 54.  0.100
Input #0, flac, from 'sample.flac':
   Metadata:
     ENCODER         : Lavf57.41.100
   Duration: 00:00:10.00, start: 0.000000, bitrate: 3094 kb/s
     Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s32 (24 bit)
[libopus @ 0x3799240] Invalid channel layout 5.1(side) for specified mapping family -1.
Output #0, opus, to 'sample.opus':
   Metadata:
     ENCODER         : Lavf57.41.100
     Stream #0:0: Unknown: none
     Metadata:
       encoder         : Lavc57.51.100 libopus
Stream mapping:
   Stream #0:0 -> #0:0 (flac (native) -> opus (libopus))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

Setting -mapping_family 1, which, according to the docs, should be the
correct setting for surround plus surround masking and LFE
optimizations enabled, results in the same error:

$ ffmpeg -y -i sample.flac -mapping_family 1 sample.opus
ffmpeg version N-81293-g81fcd91 Copyright (c) 2000-2016 the FFmpeg developers
   built with gcc 4.9.2 (Debian 4.9.2-10)
configuration: --extra-cflags='-march=native' --enable-gpl --enable-nonfree --enable-libfdk-aac --disable-runtime-cpudetect --enable-libx264 --enable-libvorbis --enable-gnutls --enable-opengl --enable-libopus --enable-libfreetype --enable-libfontconfig --enable-libfribidi --enable-libsoxr
   libavutil      55. 28.100 / 55. 28.100
   libavcodec     57. 51.100 / 57. 51.100
   libavformat    57. 46.100 / 57. 46.100
   libavdevice    57.  0.102 / 57.  0.102
   libavfilter     6. 50.100 /  6. 50.100
   libswscale      4.  1.100 /  4.  1.100
   libswresample   2.  1.100 /  2.  1.100
   libpostproc    54.  0.100 / 54.  0.100
Input #0, flac, from 'sample.flac':
   Metadata:
     ENCODER         : Lavf57.41.100
   Duration: 00:00:10.00, start: 0.000000, bitrate: 3094 kb/s
     Stream #0:0: Audio: flac, 48000 Hz, 5.1(side), s32 (24 bit)
[libopus @ 0x3a04260] Invalid channel layout 5.1(side) for specified mapping family 1.
Output #0, opus, to 'sample.opus':
   Metadata:
     ENCODER         : Lavf57.41.100
     Stream #0:0: Unknown: none
     Metadata:
       encoder         : Lavc57.51.100 libopus
Stream mapping:
   Stream #0:0 -> #0:0 (flac (native) -> opus (libopus))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height

For reference, the same file fed to opusenc:
$ opusenc sample.flac sample.opusenc.opus
Encoding using libopus 1.1.3 (audio)
-----------------------------------------------------
    Input: 48kHz 6 channels
   Output: 6 channels (4 coupled, 2 uncoupled)
           20ms packets, 320kbit/sec VBR
  Preskip: 312

Encoding complete
-----------------------------------------------------
        Encoded: 10.02 seconds
        Runtime: 1e-06 seconds
                 (1.002e+07x realtime)
          Wrote: 344242 bytes, 501 packets, 13 pages
        Bitrate: 272.683kbit/s (without overhead)
  Instant rates: 6kbit/s to 625.6kbit/s
                 (15 to 1564 bytes per packet)
       Overhead: 0.786% (container+metadata)

But the default -mapping_family -1 should work, just with surround
masking and LFE optimizations disabled. BTW, why disable those by
default with no way of manually enabling them? The way it is now, I
have two suboptimal choices:

1. Take advantage of autodetection of the channel layout and ffmpeg
selecting the appropriate mapping family but at the same time I lose
surround and LFE optimizations.

2. Select mapping family 1 for surround and get the above mentioned
optimizations but lose autosetting mapping family.

I find that a rather curious design choice. Could someone please
explain why it was made that way? Of course, 1. and 2. are
hypothetically speaking for the case when it actually works, which it
does not at the moment.

Plus, opusenc enables those optimizations by default. I cannot see, why
it would be desirable to disable them at all.

Also, I am pretty certain I had it working once. I wrote a mail to this
list, after I first discovered this new option. Then it must have
worked, because there was a noticeable difference in file size between
-mapping_family 1 and the default. But I cannot for the life of me get
back to that state with git. I have done this:

$ git checkout $(git rev-list -1 --before="Jul 18 2016 20:39" master)

because that date was just after I had tested different mapping family
settings. But maybe something in the surrounding environment changed or
I am doing something wrong with git, which still is rather difficult
for me to get my head around at times. So, any help on that front would
be greatly appreciated if your reply is "works for me".

Anyway, so far I could only git-bisect to the point when the mapping
family option was introduced, which is also the same commit which
causes above breakage (commit: 3794187). See attached git-bisect log.
As you can see by the above ffmpeg output my tests prior to writing
this mail were done with the most recent git master. So there is still
some possibility that the bug went away and came back between commits
3794187 and 81fcd91. But I wouldn't know how to easily find it by
bisecting or any other means, since I could only find two "bad" commits.

I have attached the full output of the two ffmpeg commands above with
-v 9 -loglevel 99 added. I think this way the mail stays reasonably
readable without losing any information.


Best,
Peter White

ffmpeg version N-81293-g81fcd91 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --extra-cflags='-march=native' --enable-gpl --enable-nonfree --enable-libfdk-aac --disable-runtime-cpudetect --enable-libx264 --enable-libvorbis --enable-gnutls --enable-opengl --enable-libopus --enable-libfreetype --enable-libfontconfig --enable-libfribidi --enable-libsoxr
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 46.100 / 57. 46.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 50.100 /  6. 50.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-i' ... matched as input file with argument 'sample.flac'.
Reading option 'sample.opus' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file sample.flac.
Successfully parsed a group of options.
Opening an input file: sample.flac.
[file @ 0x2749f80] Setting default whitelist 'file,crypto'
Probing flac score:50 size:2048
[flac @ 0x2749740] Format flac probed with size=2048 and score=50
[flac @ 0x2749740] Before avformat_find_stream_info() pos: 8288 bytes read:32768 seeks:0 nb_streams:1
[flac @ 0x274ab80] sample/frame number mismatch in adjacent frames
    Last message repeated 23 times
[flac @ 0x2749740] All info found
[flac @ 0x2749740] stream 0: start_time: 0.000 duration: 10.000
[flac @ 0x2749740] format: start_time: 0.000 duration: 10.000 bitrate=3094 kb/s
[flac @ 0x2749740] After avformat_find_stream_info() pos: 10336 bytes read:32768 seeks:0 frames:1
Input #0, flac, from 'sample.flac':
  Metadata:
    ENCODER         : Lavf57.41.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 3094 kb/s
    Stream #0:0, 1, 1/48000: Audio: flac, 48000 Hz, 5.1(side), s32 (24 bit)
Successfully opened the file.
Parsing a group of options: output file sample.opus.
Successfully parsed a group of options.
Opening an output file: sample.opus.
[file @ 0x274ea20] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x27495c0] Setting 'time_base' to value '1/48000'
[graph 0 input from stream 0:0 @ 0x27495c0] Setting 'sample_rate' to value '48000'
[graph 0 input from stream 0:0 @ 0x27495c0] Setting 'sample_fmt' to value 's32'
[graph 0 input from stream 0:0 @ 0x27495c0] Setting 'channel_layout' to value '0x60f'
[graph 0 input from stream 0:0 @ 0x27495c0] tb:1/48000 samplefmt:s32 samplerate:48000 chlayout:0x60f
[audio format for output stream 0:0 @ 0x274f8c0] Setting 'sample_fmts' to value 's16|flt'
[audio format for output stream 0:0 @ 0x274f8c0] Setting 'sample_rates' to value '48000|24000|16000|12000|8000'
[audio format for output stream 0:0 @ 0x274f8c0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[AVFilterGraph @ 0x274c060] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x2751f80] picking flt out of 2 ref:s32
[auto-inserted resampler 0 @ 0x2751f80] [SWR @ 0x277c540] Using fltp internally between filters
[auto-inserted resampler 0 @ 0x2751f80] ch:6 chl:5.1(side) fmt:s32 r:48000Hz -> ch:6 chl:5.1(side) fmt:flt r:48000Hz
[libopus @ 0x274e240] Invalid channel layout 5.1(side) for specified mapping family -1.
Output #0, opus, to 'sample.opus':
  Metadata:
    ENCODER         : Lavf57.41.100
    Stream #0:0, 0, 0/0: Unknown: none
    Metadata:
      encoder         : Lavc57.51.100 libopus
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> opus (libopus))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[AVIOContext @ 0x274e6c0] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x27522c0] Statistics: 32768 bytes read, 0 seeks

ffmpeg version N-81293-g81fcd91 Copyright (c) 2000-2016 the FFmpeg developers
  built with gcc 4.9.2 (Debian 4.9.2-10)
  configuration: --extra-cflags='-march=native' --enable-gpl --enable-nonfree --enable-libfdk-aac --disable-runtime-cpudetect --enable-libx264 --enable-libvorbis --enable-gnutls --enable-opengl --enable-libopus --enable-libfreetype --enable-libfontconfig --enable-libfribidi --enable-libsoxr
  libavutil      55. 28.100 / 55. 28.100
  libavcodec     57. 51.100 / 57. 51.100
  libavformat    57. 46.100 / 57. 46.100
  libavdevice    57.  0.102 / 57.  0.102
  libavfilter     6. 50.100 /  6. 50.100
  libswscale      4.  1.100 /  4.  1.100
  libswresample   2.  1.100 /  2.  1.100
  libpostproc    54.  0.100 / 54.  0.100
Splitting the commandline.
Reading option '-v' ... matched as option 'v' (set logging level) with argument '9'.
Reading option '-loglevel' ... matched as option 'loglevel' (set logging level) with argument '99'.
Reading option '-y' ... matched as option 'y' (overwrite output files) with argument '1'.
Reading option '-i' ... matched as input file with argument 'sample.flac'.
Reading option '-mapping_family' ... matched as AVOption 'mapping_family' with argument '1'.
Reading option 'sample.opus' ... matched as output file.
Finished splitting the commandline.
Parsing a group of options: global .
Applying option v (set logging level) with argument 9.
Applying option y (overwrite output files) with argument 1.
Successfully parsed a group of options.
Parsing a group of options: input file sample.flac.
Successfully parsed a group of options.
Opening an input file: sample.flac.
[file @ 0x3ac5fa0] Setting default whitelist 'file,crypto'
Probing flac score:50 size:2048
[flac @ 0x3ac5760] Format flac probed with size=2048 and score=50
[flac @ 0x3ac5760] Before avformat_find_stream_info() pos: 8288 bytes read:32768 seeks:0 nb_streams:1
[flac @ 0x3ac6ba0] sample/frame number mismatch in adjacent frames
    Last message repeated 23 times
[flac @ 0x3ac5760] All info found
[flac @ 0x3ac5760] stream 0: start_time: 0.000 duration: 10.000
[flac @ 0x3ac5760] format: start_time: 0.000 duration: 10.000 bitrate=3094 kb/s
[flac @ 0x3ac5760] After avformat_find_stream_info() pos: 10336 bytes read:32768 seeks:0 frames:1
Input #0, flac, from 'sample.flac':
  Metadata:
    ENCODER         : Lavf57.41.100
  Duration: 00:00:10.00, start: 0.000000, bitrate: 3094 kb/s
    Stream #0:0, 1, 1/48000: Audio: flac, 48000 Hz, 5.1(side), s32 (24 bit)
Successfully opened the file.
Parsing a group of options: output file sample.opus.
Successfully parsed a group of options.
Opening an output file: sample.opus.
[file @ 0x3acab20] Setting default whitelist 'file,crypto'
Successfully opened the file.
detected 4 logical cores
[graph 0 input from stream 0:0 @ 0x3ac55c0] Setting 'time_base' to value '1/48000'
[graph 0 input from stream 0:0 @ 0x3ac55c0] Setting 'sample_rate' to value '48000'
[graph 0 input from stream 0:0 @ 0x3ac55c0] Setting 'sample_fmt' to value 's32'
[graph 0 input from stream 0:0 @ 0x3ac55c0] Setting 'channel_layout' to value '0x60f'
[graph 0 input from stream 0:0 @ 0x3ac55c0] tb:1/48000 samplefmt:s32 samplerate:48000 chlayout:0x60f
[audio format for output stream 0:0 @ 0x3acb9c0] Setting 'sample_fmts' to value 's16|flt'
[audio format for output stream 0:0 @ 0x3acb9c0] Setting 'sample_rates' to value '48000|24000|16000|12000|8000'
[audio format for output stream 0:0 @ 0x3acb9c0] auto-inserting filter 'auto-inserted resampler 0' between the filter 'Parsed_anull_0' and the filter 'audio format for output stream 0:0'
[AVFilterGraph @ 0x3aca900] query_formats: 4 queried, 6 merged, 3 already done, 0 delayed
[auto-inserted resampler 0 @ 0x3acdfc0] picking flt out of 2 ref:s32
[auto-inserted resampler 0 @ 0x3acdfc0] [SWR @ 0x3af8560] Using fltp internally between filters
[auto-inserted resampler 0 @ 0x3acdfc0] ch:6 chl:5.1(side) fmt:s32 r:48000Hz -> ch:6 chl:5.1(side) fmt:flt r:48000Hz
[libopus @ 0x3aca260] Invalid channel layout 5.1(side) for specified mapping family 1.
Output #0, opus, to 'sample.opus':
  Metadata:
    ENCODER         : Lavf57.41.100
    Stream #0:0, 0, 0/0: Unknown: none
    Metadata:
      encoder         : Lavc57.51.100 libopus
Stream mapping:
  Stream #0:0 -> #0:0 (flac (native) -> opus (libopus))
Error while opening encoder for output stream #0:0 - maybe incorrect parameters such as bit_rate, rate, width or height
[AVIOContext @ 0x3aca6e0] Statistics: 0 seeks, 0 writeouts
[AVIOContext @ 0x3ace2e0] Statistics: 32768 bytes read, 0 seeks

git bisect start
# good: [309fa24f361f1c9d357f8d152c3b78718d2f870d] avformat/hls: Use an array instead of stream offset for stream mapping
git bisect good 309fa24f361f1c9d357f8d152c3b78718d2f870d
# bad: [daf421d2ab6f3e0031f46b194b5c42a09c14b15f] MAINTAINERS: add myself for libopenmpt
git bisect bad daf421d2ab6f3e0031f46b194b5c42a09c14b15f
# good: [e9394ca63dab3434bc8e869de019ecd86cb604ac] avcodec/libopenjpegenc: Set numresolutions by default to a value that is not too large
git bisect good e9394ca63dab3434bc8e869de019ecd86cb604ac
# good: [a1e3c7cf0fd982d4d82146c4cbe78f6255ae9ca2] libopusenc: Refactor to simplify forthcoming mapping_family parameter
git bisect good a1e3c7cf0fd982d4d82146c4cbe78f6255ae9ca2
# bad: [df1dc52195a5ccd43230f89c7bf24f77942e6f60] diracdsp_init: add missing ARCH_X86_64 check
git bisect bad df1dc52195a5ccd43230f89c7bf24f77942e6f60
# bad: [a7ce5b25c03abef6f3a2349b76343904513c46b3] Merge commit '84b2d3fb68caf71cff4b80b44ff865d7ae2531ce'
git bisect bad a7ce5b25c03abef6f3a2349b76343904513c46b3
# bad: [ba69a81019a2642969b108c39e3bea7d2f8ffbfa] libavfilter/af_hdcd.c: Collect HDCD stats and report
git bisect bad ba69a81019a2642969b108c39e3bea7d2f8ffbfa
# bad: [ce466d0a15588da318e306c3e58d2778d6340e5d] fate/apng : add test for apng decoding
git bisect bad ce466d0a15588da318e306c3e58d2778d6340e5d
# bad: [293484fa5e444bf0437d010f8e9808555102eb90] avcodec: add missing xmm/neon clobber test wrappers for the new decode API
git bisect bad 293484fa5e444bf0437d010f8e9808555102eb90
# bad: [d5edb6c0483b04b0f91c011c4c4753bd440fec9b] lavf/aiffdec: Support QDMC demuxing.
git bisect bad d5edb6c0483b04b0f91c011c4c4753bd440fec9b
# bad: [37941878f193a2316c514bd5ba55bfe9d2dfdfcf] libopusenc: Add channel mapping family argument
git bisect bad 37941878f193a2316c514bd5ba55bfe9d2dfdfcf
# first bad commit: [37941878f193a2316c514bd5ba55bfe9d2dfdfcf] libopusenc: Add channel mapping family argument

_______________________________________________
ffmpeg-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
[email protected] with subject "unsubscribe".

Reply via email to