Discussion:
[FFmpeg-user] AC-3 Dolby Digital 5.1 Encoding
Chase Patterson
2012-05-24 23:28:20 UTC
Permalink
Hi,

I'm mixing audio for a movie on Ardour (an audio editing software), which
can't export to AC3, but it can export multiple channels to other formats,
e.g. FLAC. So I have it encoded in FLAC with 5.1 surround sound. I'd like
to use ffmpeg to convert it to AC3 at 48kHz and 640kb/s with 5.1 surround
(Dolby Digital).

Here's what I have so far, but I'd like to change (or make sure it's
correct) the channel layout.

ffmpeg -i Session.flac -s:a 48k -ab 640k -acodec ac3 -ac 6 Session.ac3

Which returns

ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
built on May 9 2012 17:51:07 with gcc 4.7.0 20120505 (prerelease)
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis
--enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora
--enable-libgsm --enable-libspeex --enable-postproc --enable-shared
--enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libschroedinger --enable-libopenjpeg --enable-librtmp
--enable-libpulse --enable-gpl --enable-version3 --enable-runtime-cpudetect
--disable-debug --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
[flac @ 0x1c003a0] max_analyze_duration 5000000 reached at 5016000
Input #0, flac, from 'Session.flac':
Duration: 00:00:14.00, bitrate: 1010 kb/s
Stream #0:0: Audio: flac, 48000 Hz, 5.1, s32
Incompatible sample format 's32' for codec 'ac3', auto-selecting format
'flt'
[ac3 @ 0x1c07920] channel_layout not specified
[ac3 @ 0x1c07920] No channel layout specified. The encoder will guess the
layout, but it might be incorrect.
Output #0, ac3, to 'test.ac3':
Metadata:
encoder : Lavf53.32.100
Stream #0:0: Audio: ac3, 48000 Hz, 5.1(side), flt, 640 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (flac -> ac3)
Press [q] to stop, [?] for help
size= 1095kB time=00:00:14.01 bitrate= 640.0kbits/s
video:0kB audio:1095kB global headers:0kB muxing overhead 0.000000%

That leads me to believe that it's using a channel layout of "5.1(side)"
(maybe assuming the surround speakers are on the sides, rather than behind,
as I want). Also, it automatically sets the sample format to "flt". Is this
what I want, or how can I change it?

Thank you!


Chase
Carl Eugen Hoyos
2012-05-25 06:09:23 UTC
Permalink
Post by Chase Patterson
Stream #0:0: Audio: ac3, 48000 Hz, 5.1(side), flt, 640 kb/s
That leads me to believe that it's using a channel layout of "5.1(side)"
Please compare with a random 5.1 Dolby stream from DVB or DVD,
it should be identical.
Post by Chase Patterson
(maybe assuming the surround speakers are on the sides, rather than behind,
as I want).
Also, it automatically sets the sample format to "flt". Is this
what I want, or how can I change it?
It feeds "flt" into the encoder that outputs "Dolby".
There is also a (slower) Dolby encoder that uses "s16" as input,
but it has no advantage.

Carl Eugen
Chase Patterson
2012-05-26 14:13:21 UTC
Permalink
So, the command I figured out (ffmpeg -i Session.flac -s:a 48k -ab
640k -acodec ac3 -ac 6 Session.ac3) works, but even though it does in
fact have 6 channels, it plays in stereo. Am I missing an argument
that maps the channels correctly? I also tried converting from a wav
version of the file (that's also encoded in 5.1 surround, and plays as
such), but with the same result.

Does anyone have any idea what I'm missing?


Thanks,
Chase
Post by Chase Patterson
Hi,
I'm mixing audio for a movie on Ardour (an audio editing software), which
can't export to AC3, but it can export multiple channels to other formats,
e.g. FLAC. So I have it encoded in FLAC with 5.1 surround sound. I'd like to
use ffmpeg to convert it to AC3 at 48kHz and 640kb/s with 5.1 surround
(Dolby Digital).
Here's what I have so far, but I'd like to change (or make sure it's
correct) the channel layout.
ffmpeg -i Session.flac -s:a 48k -ab 640k -acodec ac3 -ac 6 Session.ac3
Which returns
ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
  built on May  9 2012 17:51:07 with gcc 4.7.0 20120505 (prerelease)
  configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis
--enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora
--enable-libgsm --enable-libspeex --enable-postproc --enable-shared
--enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libschroedinger --enable-libopenjpeg --enable-librtmp
--enable-libpulse --enable-gpl --enable-version3 --enable-runtime-cpudetect
--disable-debug --disable-static
  libavutil      51. 35.100 / 51. 35.100
  libavcodec     53. 61.100 / 53. 61.100
  libavformat    53. 32.100 / 53. 32.100
  libavdevice    53.  4.100 / 53.  4.100
  libavfilter     2. 61.100 /  2. 61.100
  libswscale      2.  1.100 /  2.  1.100
  libswresample   0.  6.100 /  0.  6.100
  libpostproc    52.  0.100 / 52.  0.100
  Duration: 00:00:14.00, bitrate: 1010 kb/s
    Stream #0:0: Audio: flac, 48000 Hz, 5.1, s32
Incompatible sample format 's32' for codec 'ac3', auto-selecting format
'flt'
layout, but it might be incorrect.
    encoder         : Lavf53.32.100
    Stream #0:0: Audio: ac3, 48000 Hz, 5.1(side), flt, 640 kb/s
  Stream #0:0 -> #0:0 (flac -> ac3)
Press [q] to stop, [?] for help
size=    1095kB time=00:00:14.01 bitrate= 640.0kbits/s
video:0kB audio:1095kB global headers:0kB muxing overhead 0.000000%
That leads me to believe that it's using a channel layout of "5.1(side)"
(maybe assuming the surround speakers are on the sides, rather than behind,
as I want). Also, it automatically sets the sample format to "flt". Is this
what I want, or how can I change it?
Thank you!
Chase
Carl Eugen Hoyos
2012-05-26 14:30:38 UTC
Permalink
Post by Chase Patterson
So, the command I figured out (ffmpeg -i Session.flac -s:a 48k -ab
640k -acodec ac3 -ac 6 Session.ac3) works, but even though it does in
fact have 6 channels, it plays in stereo.
This seems unlikely / difficult to understand.
Above command does not "play" anything, so I assume you used
something else to test the resulting file. What was it?

And a sample will probably be needed, or you use
samples.ffmpeg.org/multichannel/6_Channel_ID.flac to make sure
we are talking about the same input file.

Carl Eugen
Joshua Tidsbury
2012-05-26 14:58:24 UTC
Permalink
You should probably explicitly define the channel layout. Here are some notes from an internal app of mine that should assist in translating the various Dolby terminology into ffmpeg terminology:

ac3_center_dmix (-center_mixlev -ltrt_cmixlev -loro_cmixlev; float)
ac3_surround_dmix (-surround_mixlev -ltrt_surmixlev -loro_surmixlev; float)
ac3_copyright_bit (-copyright; 0 or 1)
ac3_dialnorm (-dialnorm; negative int)
ac3_original_stream (-original; 0 or 1)
ac3_dmix_mode (-dmix_mode; 0,1,2)

ac3_channel_l = 1
ac3_channel_r = 2
ac3_channel_c = 4
ac3_channel_lfe = 8
ac3_channel_ls = 16
ac3_channel_rs = 32
ac3_channel_lsb = 512
ac3_channel_rsb = 1024

-channel_layout: 1_0 = 4, 2_0 = 3, 2_1 = 11, 3_0 = 7, 3_1 = 15, 5_0 = 55, 5_1 = 63, 7_0 = 1591, 7_1 = 1599

And an example for converting a poly bwav into a fully formatted ac3 with metadata:

ffmpeg -i T-Vox\ Channel\ Ident.WAV -vn -acodec ac3 -ac 6 -ar 48000 -ab 448k -dialnorm -24 -dsur_mode 0 -original 1 -dmix_mode 2 -channel_layout 63 result.ac3

Hope that helps,
Josh


--------------
Josh Tidsbury | CTV
m: 416.433.3968
Post by Chase Patterson
So, the command I figured out (ffmpeg -i Session.flac -s:a 48k -ab
640k -acodec ac3 -ac 6 Session.ac3) works, but even though it does in
fact have 6 channels, it plays in stereo. Am I missing an argument
that maps the channels correctly? I also tried converting from a wav
version of the file (that's also encoded in 5.1 surround, and plays as
such), but with the same result.
Does anyone have any idea what I'm missing?
Thanks,
Chase
Post by Chase Patterson
Hi,
I'm mixing audio for a movie on Ardour (an audio editing software), which
can't export to AC3, but it can export multiple channels to other formats,
e.g. FLAC. So I have it encoded in FLAC with 5.1 surround sound. I'd like to
use ffmpeg to convert it to AC3 at 48kHz and 640kb/s with 5.1 surround
(Dolby Digital).
Here's what I have so far, but I'd like to change (or make sure it's
correct) the channel layout.
ffmpeg -i Session.flac -s:a 48k -ab 640k -acodec ac3 -ac 6 Session.ac3
Which returns
ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
built on May 9 2012 17:51:07 with gcc 4.7.0 20120505 (prerelease)
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis
--enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora
--enable-libgsm --enable-libspeex --enable-postproc --enable-shared
--enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libschroedinger --enable-libopenjpeg --enable-librtmp
--enable-libpulse --enable-gpl --enable-version3 --enable-runtime-cpudetect
--disable-debug --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
Duration: 00:00:14.00, bitrate: 1010 kb/s
Stream #0:0: Audio: flac, 48000 Hz, 5.1, s32
Incompatible sample format 's32' for codec 'ac3', auto-selecting format
'flt'
layout, but it might be incorrect.
encoder : Lavf53.32.100
Stream #0:0: Audio: ac3, 48000 Hz, 5.1(side), flt, 640 kb/s
Stream #0:0 -> #0:0 (flac -> ac3)
Press [q] to stop, [?] for help
size= 1095kB time=00:00:14.01 bitrate= 640.0kbits/s
video:0kB audio:1095kB global headers:0kB muxing overhead 0.000000%
That leads me to believe that it's using a channel layout of "5.1(side)"
(maybe assuming the surround speakers are on the sides, rather than behind,
as I want). Also, it automatically sets the sample format to "flt". Is this
what I want, or how can I change it?
Thank you!
Chase
_______________________________________________
ffmpeg-user mailing list
http://ffmpeg.org/mailman/listinfo/ffmpeg-user
Carl Eugen Hoyos
2012-05-26 15:14:13 UTC
Permalink
Post by Joshua Tidsbury
You should probably explicitly define the channel layout.
This is certainly a possibility, but I since I tested many
(including unusual) layouts with ffmpeg and a receiver /
hardware decoder and I do not remember a case where
specifying the layout was really necessary:
Could you provide an example where it is necessary?
(except raw pcm input, of course)

There may be bug in the default behaviour that can be fixed.

Carl Eugen
Joshua Tidsbury
2012-05-26 15:37:32 UTC
Permalink
Post by Carl Eugen Hoyos
This is certainly a possibility, but I since I tested many
(including unusual) layouts with ffmpeg and a receiver /
hardware decoder and I do not remember a case where
Could you provide an example where it is necessary?
(except raw pcm input, of course)
There may be bug in the default behaviour that can be fixed.
Carl Eugen
To be honest, I don't have an example. Only many years of experience as a broadcaster that has led me never to trust anything associated with the words "default" and "Dolby" in the same sentence :)

We always explicitly define all metadata flags for every encode as its the only way to reasonably expect the playback behaviour to be appropriate, especially with regards to dialnorm, mixdown coefficients, and compression methodologies. I suppose explicitly defining the output format mostly stems from the use of Dolby's hardware encoders.

Thanks!
Josh
Chase Patterson
2012-05-27 14:44:28 UTC
Permalink
Thanks everybody! It turns out, Totem (the Gnome Movie Player) doesn't
recognize it as surround sound correctly, but vlc does.

There was only a small difference in ffmpeg's output to the terminal
with the different commands, that is not warning about not specifying
a channel layout anymore, and it says "5.1" rather than "5.1(side)".

ffmpeg -i Session.wav -vn -acodec ac3 -ac 6 -ar 48000 -ab 640k
-dialnorm -24 -dsur_mode 0 -original 1 -dmix_mode 2 -channel_layout 63
Session.ac3
ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
built on May 9 2012 17:51:07 with gcc 4.7.0 20120505 (prerelease)
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis
--enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora
--enable-libgsm --enable-libspeex --enable-postproc --enable-shared
--enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libschroedinger --enable-libopenjpeg --enable-librtmp
--enable-libpulse --enable-gpl --enable-version3
--enable-runtime-cpudetect --disable-debug --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
[wav @ 0x9493a0] max_analyze_duration 5000000 reached at 5003458
Input #0, wav, from 'Session.wav':
Duration: 00:00:14.00, bitrate: 6912 kb/s
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 6
channels, s32, 6912 kb/s
Incompatible sample format 's32' for codec 'ac3', auto-selecting format 'flt'
Output #0, ac3, to 'Session.ac3':
Metadata:
encoder : Lavf53.32.100
Stream #0:0: Audio: ac3, 48000 Hz, 5.1, flt, 640 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s24le -> ac3)
Press [q] to stop, [?] for help
size= 1095kB time=00:00:14.01 bitrate= 640.0kbits/s
video:0kB audio:1095kB global headers:0kB muxing overhead 0.000000%


ffmpeg -i Session.wav -s:a 48k -ab 640k -acodec ac3 -ac 6 Session2.ac3
ffmpeg version 0.10.3 Copyright (c) 2000-2012 the FFmpeg developers
built on May 9 2012 17:51:07 with gcc 4.7.0 20120505 (prerelease)
configuration: --prefix=/usr --enable-libmp3lame --enable-libvorbis
--enable-libxvid --enable-libx264 --enable-libvpx --enable-libtheora
--enable-libgsm --enable-libspeex --enable-postproc --enable-shared
--enable-x11grab --enable-libopencore_amrnb --enable-libopencore_amrwb
--enable-libschroedinger --enable-libopenjpeg --enable-librtmp
--enable-libpulse --enable-gpl --enable-version3
--enable-runtime-cpudetect --disable-debug --disable-static
libavutil 51. 35.100 / 51. 35.100
libavcodec 53. 61.100 / 53. 61.100
libavformat 53. 32.100 / 53. 32.100
libavdevice 53. 4.100 / 53. 4.100
libavfilter 2. 61.100 / 2. 61.100
libswscale 2. 1.100 / 2. 1.100
libswresample 0. 6.100 / 0. 6.100
libpostproc 52. 0.100 / 52. 0.100
[wav @ 0x1bcc3a0] max_analyze_duration 5000000 reached at 5003458
Input #0, wav, from 'Session.wav':
Duration: 00:00:14.00, bitrate: 6912 kb/s
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, 6
channels, s32, 6912 kb/s
Incompatible sample format 's32' for codec 'ac3', auto-selecting format 'flt'
[ac3 @ 0x1bcd240] channel_layout not specified
[ac3 @ 0x1bcd240] No channel layout specified. The encoder will guess
the layout, but it might be incorrect.
Output #0, ac3, to 'Session2.ac3':
Metadata:
encoder : Lavf53.32.100
Stream #0:0: Audio: ac3, 48000 Hz, 5.1(side), flt, 640 kb/s
Stream mapping:
Stream #0:0 -> #0:0 (pcm_s24le -> ac3)
Press [q] to stop, [?] for help
size= 1095kB time=00:00:14.01 bitrate= 640.0kbits/s
video:0kB audio:1095kB global headers:0kB muxing overhead 0.000000%

I don't know if there's actually a difference in the outputted file,
or in its metadata, but both ways turn out to work in the long run.
Thank you again!


Chase
Joshua Tidsbury
2012-05-27 15:01:21 UTC
Permalink
Post by Chase Patterson
Thanks everybody! It turns out, Totem (the Gnome Movie Player) doesn't
recognize it as surround sound correctly, but vlc does.
There was only a small difference in ffmpeg's output to the terminal
with the different commands, that is not warning about not specifying
a channel layout anymore, and it says "5.1" rather than "5.1(side)".
It's in the metadata (channel labelling). In most cases, set top boxes and receivers will treat them the same, but by specifying mode 63, you've forced the metadata to match the standard Dolby metadata for an ITU 5.1 program stream.

I did notice that you utilized -24 as the dialnorm value, which was in my example, but isn't necessarily correct for your program. I would encourage you to measure the long term LEqA (Dolby) or ITU-R BS1770 loudness of your program in order to determine the actual loudness value in order to be presenting valid metadata and be in compliance.

Also, I provided a downmix value of 2, which causes the program stream to suggest (note: not necessarily enforce) a preferred downmix mode of Lo/Ro, which entails a simple folddown of the content to stereo. This is as opposed to Lt/Rt (which would be option 1) which causes a 90 degree phase shift to the surround channels prior to performing the folddown, and is designed to improve later upmixing should the end consumer's receiver be in Dolby ProLogic mode, but can cause other interesting artifacts due to the phase shift.

Yes, as odd as it sounds to hear that folks would take a stereo output of a device (which is actually a downmix of a true 5.1 program) and then run it through an upmixer afterwards, it happens more often than you'd think.

I won't argue that one mode is better than the other. It tends to be highly content sensitive. I would suggest you encode in both modes and compare the stereo mixdown output to see which provides a better experience. I tend to lean towards Lo/Ro for most of the mixing I do, especially if there is a great degree of discretely mixed 5.1 music as part of the program, but I'd encourage you to listen to both so you can understand the results and ensure the greatest portability of your final mix.

Take care,
Josh


Joshua Tidsbury | CTV Television
t 416.384.7253 | m 416.433.3968 | ***@bellmedia.ca
Chase Patterson
2012-05-27 15:36:00 UTC
Permalink
Post by Joshua Tidsbury
It's in the metadata (channel labelling). In most cases, set top boxes and receivers will treat them the same, but by specifying mode 63, you've forced the metadata to match the standard Dolby metadata for an ITU 5.1 program stream.
I did notice that you utilized -24 as the dialnorm value, which was in my example, but isn't necessarily correct for your program. I would encourage you to measure the long term LEqA (Dolby) or ITU-R BS1770 loudness of your program in order to determine the actual loudness value in order to be presenting valid metadata and be in compliance.
Also, I provided a downmix value of 2, which causes the program stream to suggest (note: not necessarily enforce) a preferred downmix mode of Lo/Ro, which entails a simple folddown of the content to stereo. This is as opposed to Lt/Rt (which would be option 1) which causes a 90 degree phase shift to the surround channels prior to performing the folddown, and is designed to improve later upmixing should the end consumer's receiver be in Dolby ProLogic mode, but can cause other interesting artifacts due to the phase shift.
Yes, as odd as it sounds to hear that folks would take a stereo output of a device (which is actually a downmix of a true 5.1 program) and then run it through an upmixer afterwards, it happens more often than you'd think.
I won't argue that one mode is better than the other. It tends to be highly content sensitive. I would suggest you encode in both modes and compare the stereo mixdown output to see which provides a better experience. I tend to lean towards Lo/Ro for most of the mixing I do, especially if there is a great degree of discretely mixed 5.1 music as part of the program, but I'd encourage you to listen to both so you can understand the results and ensure the greatest portability of your final mix.
Take care,
Josh
Oh, I see. I've been reading through the myriad of ffmpeg arguments
that just set certain metadata options. I'll keep the -dialnorm option
in mind when I'm actually encoding the audio for a dvd/blu ray burn.

I guess you really have to guess what downmix option you want to use,
as I know my stereo surround sound system I use with my TV has tons of
options, e.g. Dolby Digital (not downmixed), Dolby Pro Logic, Stereo
Surround (downmixes to stereo, then mirrors R and Rs, mirrors L and
Ls, and combines both for C), and many more.

Thanks,
Chase
Joshua Tidsbury
2012-05-27 15:42:07 UTC
Permalink
Post by Chase Patterson
I guess you really have to guess what downmix option you want to use,
as I know my stereo surround sound system I use with my TV has tons of
options, e.g. Dolby Digital (not downmixed), Dolby Pro Logic, Stereo
Surround (downmixes to stereo, then mirrors R and Rs, mirrors L and
Ls, and combines both for C), and many more.
Oh yeah, there's a million awful things that home set top boxes and receivers can do to your mix.

Thankfully, most folks will either likely be listening to the 5.1 mix via Dolby Digital, or a stereo downmix (utilizing the mode described in your metadata, hopefully). If you create a ITU downmix in your DAW that folds C (at -3 dB) to L and R, and folds Ls and Rs forward to L and R respectively with a -3 dB gain reduction, and LFE at -6 or so to L & R, you can at least test the Lo/Ro option while you are mixing. At least then that version will be predictable. Without a plugin that mimics the Lt/Rt downmix process, that's much harder to guess.

So I'd set up a simple ITU folddown to check your mix against while mixing, and then use mode 2 downmix (Lo/Ro). At least that way you can hear that final result while doing the mix.

Take care,
Josh


Joshua Tidsbury | CTV Television
t 416.384.7253 | m 416.433.3968 | ***@bellmedia.ca
Andy Furniss
2012-05-27 18:13:08 UTC
Permalink
Post by Joshua Tidsbury
Post by Chase Patterson
I guess you really have to guess what downmix option you want to use,
as I know my stereo surround sound system I use with my TV has tons of
options, e.g. Dolby Digital (not downmixed), Dolby Pro Logic, Stereo
Surround (downmixes to stereo, then mirrors R and Rs, mirrors L and
Ls, and combines both for C), and many more.
Oh yeah, there's a million awful things that home set top boxes and receivers can do to your mix.
Thankfully, most folks will either likely be listening to the 5.1 mix via Dolby Digital, or a stereo downmix (utilizing the mode described in your metadata, hopefully). If you create a ITU downmix in your DAW that folds C (at -3 dB) to L and R, and folds Ls and Rs forward to L and R respectively with a -3 dB gain reduction, and LFE at -6 or so to L& R, you can at least test the Lo/Ro option while you are mixing. At least then that version will be predictable. Without a plugin that mimics the Lt/Rt downmix process, that's much harder to guess.
So I'd set up a simple ITU folddown to check your mix against while mixing, and then use mode 2 downmix (Lo/Ro). At least that way you can hear that final result while doing the mix.
Apologies for butting in - but you seem to have lots of experience with ac3.

Am I missing something obvious with ffmpeg, or is there no way to
specify a drc profile eg. film standard.

It would be handy (for my ears at least) to reduce with metadata full
range sources, but I can't see any encoder option for this. I know drc
is implemented for decode - is there a way when encoding?

TIA
Andy.
Joshua Tidsbury
2012-05-27 20:15:31 UTC
Permalink
Am I missing something obvious with ffmpeg, or is there no way to specify a drc profile eg. film standard.
Not that I'm aware of. I'd really like to be wrong about that though...

Do note that the dialnorm value plays heavily into how the decoder applies the drc profile (in terms of threshold values), so ensuring it is set correctly and accurately will improve playback when drc is enabled on the decoder.

I'm hopeful that someone else on this list can inform us of the variables/values to set the drc profile though...

Thanks,
Josh
Chase Patterson
2012-06-03 20:29:43 UTC
Permalink
Sorry for bringing this thread back from the dead, but I have a couple
other inquiries regarding the same original problem (described by the
subject).

The command below mostly works, but I'm still not completely satisfied.

ffmpeg -i original.wav -vn -acodec ac3 -ac 6 -ar
48000 -ab 640k -dialnorm -24 -dsur_mode 0 -original 1 -dmix_mode 1
-channel_layout 63 final.ac3

It outputs a valid 5.1-channel AC-3 file, but not all players recognize it
as such; Some play it as stereo (e.g. VLC sees that it's 5.1, but Totem
thinks it's stereo). Is there some metadata that some players require?
I've tested it, and Totem can in fact play most 5.1 surround AC-3s
correctly.

The other thing is the -channel_layout value (generously prescribed by
Joshua Tidsbury). A value of 63 indeed works, and ffmpeg prints that it's
encoding in "5.1" (if I don't specify a -channel_layout, it prints
"5.1(side)". So, my question is, where did this value come from?

I was reading in the documentation, and part of it led me to believe that it
could be found in /libavutil/audioconvert.c, but I looked, and the values
I find there are not accepted by ffmpeg, so I'd assume that is only for
abuffer (which is the heading under which I found this info in the docs).


Chase
Carl Eugen Hoyos
2012-06-03 21:34:01 UTC
Permalink
Post by Chase Patterson
The other thing is the -channel_layout value
As said before, please do not use it, it makes no
difference for your use case.
(It may be needed if you encode raw pcm audio.)

To answer your question:
channel_layout is a binary representation of the available
channels.

To test if the encoded ac-3 stream is indeed a surround
stream, I suggest a hardware decoder.

Carl Eugen
Chase Patterson
2012-06-03 21:56:09 UTC
Permalink
Post by Carl Eugen Hoyos
Post by Chase Patterson
The other thing is the -channel_layout value
As said before, please do not use it, it makes no
difference for your use case.
(It may be needed if you encode raw pcm audio.)
Oh, ok, I see.
Post by Carl Eugen Hoyos
To test if the encoded ac-3 stream is indeed a surround
stream, I suggest a hardware decoder.
It is indeed a surround stream. I will eventually test it on a DVD and a
set-top box, which I'm assuming will work correctly. I'm just wondering
how Totem decides if something is surround or not, and if there's some
ffmpeg option that encodes additional metadata to say this.

Like I said, I'm pretty happy with how this works, since it seems to be
functional, just curious as to why these little things happen.


Thank you!
Chase
Joshua Tidsbury
2012-06-03 22:26:11 UTC
Permalink
I'm just wondering how Totem decides if something is surround or not, and if there's some ffmpeg option that encodes additional metadata to say this.
You'd probably have to ask the developers, but it is the channel_layout flag that specifies this insofar as the ac3 spec is concerned. There isn't any further metadata required.

I would concur with Carl that a hardware decoder is the only reliable test of the encoded stream. We've generally found VLC to be quite representative though.

Thanks,
Josh

-----
Josh Tidsbury
Carl Eugen Hoyos
2012-06-03 22:32:28 UTC
Permalink
Post by Joshua Tidsbury
I would concur with Carl that a hardware decoder is the
only reliable test of the encoded stream.
I believe it is the easiest reliable test.
(I once unsuccessfully searched for a certified decoder).
Post by Joshua Tidsbury
We've generally found VLC to be quite representative though.
Which uses liba52 (ancient) or FFmpeg while I suspect
hardware decoders generally are Dolby-certified.

Carl Eugen
Joshua Tidsbury
2012-06-04 00:54:10 UTC
Permalink
Post by Carl Eugen Hoyos
I believe it is the easiest reliable test.
(I once unsuccessfully searched for a certified decoder).
The only certified software decoder I know of is by Neyrinck:

http://www.neyrinck.com/en/products/dolby-digital

It's far from free though, which isn't surprising given the license fees Dolby charges in order to certify something...

Take care,
Josh

Loading...