Log in

View Full Version : Getting ffmpeg eac3 encoding to work


MrVideo
14th March 2017, 07:34
Summary: I've used ffmpeg to encode an eac3 5.1 audio stream, but the video editing program VideoReDo does not like the result.

I use the following to do the encoding:
ffmpeg -i front_left.wav -i front_right.wav -i front_center.wav -i lfe.wav \
-i back_left.wav -i back_right.wav \
-filter_complex "[0:a][1:a][2:a][3:a][4:a][5:a]amerge=inputs=6[aout]" \
-map "[aout]" -acodec eac3 -ab 999k outputfile.ac3

The output from such an encode:
ffmpeg version N-52837-g399f6ef Copyright (c) 2000-2013 the FFmpeg developers
built on May 7 2013 01:09:00 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib
--enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray
--enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
--enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora
--enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 29.100 / 52. 29.100
libavcodec 55. 7.100 / 55. 7.100
libavformat 55. 4.101 / 55. 4.101
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 63.101 / 3. 63.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
[wav @ 027f8420] max_analyze_duration 5000000 reached at 5005000 microseconds
Guessed Channel Layout for Input Stream #0.0 : mono
Input #0, wav, from 'g:\\test 00 (Left).wav':
Duration: 00:12:22.84, bitrate: 1152 kb/s
Stream #0:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s32, 1152 kb/s
[wav @ 029a1320] max_analyze_duration 5000000 reached at 5005000 microseconds
Guessed Channel Layout for Input Stream #1.0 : mono
Input #1, wav, from 'g:\\test 01 (Right).wav':
Duration: 00:12:22.84, bitrate: 1152 kb/s
Stream #1:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s32, 1152 kb/s
[wav @ 02a76180] max_analyze_duration 5000000 reached at 5005000 microseconds
Guessed Channel Layout for Input Stream #2.0 : mono
Input #2, wav, from 'g:\\test 02 (Center).wav':
Duration: 00:12:22.84, bitrate: 1152 kb/s
Stream #2:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s32, 1152 kb/s
[wav @ 02b4c1c0] max_analyze_duration 5000000 reached at 5005000 microseconds
Guessed Channel Layout for Input Stream #3.0 : mono
Input #3, wav, from 'g:\\test 03 (LFE).wav':
Duration: 00:12:22.84, bitrate: 1152 kb/s
Stream #3:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s32, 1152 kb/s
[wav @ 02c172a0] max_analyze_duration 5000000 reached at 5005000 microseconds
Guessed Channel Layout for Input Stream #4.0 : mono
Input #4, wav, from 'g:\\test 04 (Left Surround).wav':
Duration: 00:12:22.84, bitrate: 1152 kb/s
Stream #4:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s32, 1152 kb/s
[wav @ 02cd87c0] max_analyze_duration 5000000 reached at 5005000 microseconds
Guessed Channel Layout for Input Stream #5.0 : mono
Input #5, wav, from 'g:\\test 05 (Right Surround).wav':
Duration: 00:12:22.84, bitrate: 1152 kb/s
Stream #5:0: Audio: pcm_s24le ([1][0][0][0] / 0x0001), 48000 Hz, mono, s32, 1152 kb/s
[Parsed_amerge_0 @ 02dae380] No channel layout for input 1
[Parsed_amerge_0 @ 02dae380] Input channel layouts overlap: output layout will be determined by the number of distinct input channels
Output #0, ac3, to 'g:\\test.ac3':
Metadata:
encoder : Lavf55.4.101
Stream #0:0: Audio: eac3, 48000 Hz, 5.1, fltp, 1280 kb/s
Stream mapping:
Stream #0:0 (pcm_s24le) -> amerge:in0
Stream #1:0 (pcm_s24le) -> amerge:in1
Stream #2:0 (pcm_s24le) -> amerge:in2
Stream #3:0 (pcm_s24le) -> amerge:in3
Stream #4:0 (pcm_s24le) -> amerge:in4
Stream #5:0 (pcm_s24le) -> amerge:in5
amerge -> Stream #0:0 (eac3)
Press [q] to stop, [?] for help
size= 116070kB time=00:12:22.84 bitrate=1280.0kbits/s
video:0kB audio:116070kB subtitle:0 global headers:0kB muxing overhead 0.000000%
Here is what ffmpeg thinks of the file:
ffmpeg -i test.ac3
ffmpeg version N-52837-g399f6ef Copyright (c) 2000-2013 the FFmpeg developers
built on May 7 2013 01:09:00 with gcc 4.7.3 (GCC)
configuration: --enable-gpl --enable-version3 --disable-w32threads --enable-avisynth --enable-bzlib
--enable-fontconfig --enable-frei0r --enable-gnutls --enable-iconv --enable-libass --enable-libbluray
--enable-libcaca --enable-libfreetype --enable-libgsm --enable-libilbc --enable-libmp3lame
--enable-libopencore-amrnb --enable-libopencore-amrwb --enable-libopenjpeg --enable-libopus
--enable-librtmp --enable-libschroedinger --enable-libsoxr --enable-libspeex --enable-libtheora
--enable-libtwolame --enable-libvo-aacenc --enable-libvo-amrwbenc --enable-libvorbis --enable-libvpx
--enable-libx264 --enable-libxavs --enable-libxvid --enable-zlib
libavutil 52. 29.100 / 52. 29.100
libavcodec 55. 7.100 / 55. 7.100
libavformat 55. 4.101 / 55. 4.101
libavdevice 55. 0.100 / 55. 0.100
libavfilter 3. 63.101 / 3. 63.101
libswscale 2. 2.100 / 2. 2.100
libswresample 0. 17.102 / 0. 17.102
libpostproc 52. 3.100 / 52. 3.100
[eac3 @ 027f7ce0] max_analyze_duration 5000000 reached at 5008000 microseconds
[eac3 @ 027f7ce0] Estimating duration from bitrate, this may be inaccurate
Input #0, eac3, from 'test.ac3':
Duration: 00:12:22.85, start: 0.000000, bitrate: 1280 kb/s
Stream #0:0: Audio: eac3, 48000 Hz, 5.1(side), fltp, 1280 kb/s
At least one output file must be specified
And this is what eac3to thinks of the file:
eac3to test.ac3
E-AC3, 5.1 channels, 0:12:23, 1280kbps, 48kHz
All looks good to me, but VideoReDo refuses to mux the MPEG-2 video stream file with this eac3 stream. If I mux it with tsMuxer, VideoReDo refuses to open the TS file, complaining about no PIDs.

If I create a MKV file from the TS file, VideoReDo complains that no audio was found.

But, VLC will play it with sound.

Lastly, I have MKV files with eac3 audio that others have created and VideoReDo has no problems opening them.

Any ideas as to what I could be doing wrong? Other things to try?

Side note: I tried using ffmpeg 3.2.4, but it crashed on my XP system, not being able to find an entry point in the kernel.

Update: While version 2.8.6 runs, the results are the same.

hello_hello
14th March 2017, 07:53
I don't have any answers, but there's a newer XP compatible flavour of ffmpeg here:
https://sourceforge.net/projects/ffmpegwindowsbi/

MrVideo
14th March 2017, 08:32
I don't have any answers, but there's a newer XP compatible flavour of ffmpeg here:
https://sourceforge.net/projects/ffmpegwindowsbi/
It too has the entry point error.

MrVideo
14th March 2017, 08:59
Added tidbits...

eac3to declares the third-party MKV file's audio to be:
EAC3, English, 5.1 channels, 48kHz
No bitrate.
The ffmpeg generated file is listed as:
E-AC3, 5.1 channels, 1280kbps, 48kHz
Notice that the one that works is EAC3, while ffmpeg is E-AC3.

MrVideo
20th June 2017, 02:43
Bump. Hopefully this will fall under fresh eyes.

hello_hello
20th June 2017, 23:19
This is newer than the last ffmpeg build I linked to, and like that one, it also runs on my XP PC.
https://github.com/rdp/ffmpeg-windows-build-helpers/issues/219#issuecomment-306066471

I didn't notice before, but try specifying eac3 as the output file extension instead of ac3.

tebasuna51
21st June 2017, 16:00
Added tidbits...

eac3to declares the third-party MKV file's audio to be:
EAC3, English, 5.1 channels, 48kHz
No bitrate.
The ffmpeg generated file is listed as:
E-AC3, 5.1 channels, 1280kbps, 48kHz
Notice that the one that works is EAC3, while ffmpeg is E-AC3.

Is a know problem related with eac3to and EAC3 tracks in MKV container. It is not a ffmpeg problem.

Original file:
MKV, 1 video track, 1 audio tracks, 0:57:33, 24p /1.001
1: h264/AVC, 720p24 /1.001 (16:9)
2: EAC3, English, 5.1 channels, 48kHz "640 Kbps"
Bitstream parsing for track 2 failed. <WARNING>
Demuxing this track may still produce correct results - or not. <WARNING>

Recoded the EAC3 to EAC3 448 Kb/s with ffmpeg:

E-AC3, 5.1 channels, 0:57:33, 448kbps, 48kHz

Muxed in mkv:

MKV, 1 video track, 1 audio track, 0:57:33, 24p /1.001
1: h264/AVC, 720p24 /1.001 (16:9)
2: EAC3, English, 5.1 channels, 48kHz "448 Kbps"
Bitstream parsing for track 2 failed. <WARNING>
Demuxing this track may still produce correct results - or not. <WARNING>

Muxed in m2ts:

M2TS, 1 video track, 1 audio track, 0:57:33, 24p /1.001
1: h264/AVC, 720p24 /1.001 (16:9)
2: E-AC3, English, 5.1 channels, 448kbps, 48kHz

Without warnings.

tebasuna51
21st June 2017, 16:26
All looks good to me, but VideoReDo refuses to mux the MPEG-2 video stream file with this eac3 stream. If I mux it with tsMuxer, VideoReDo refuses to open the TS file, complaining about no PIDs.

The same here with the m2ts (or ts).

But work with the mkv file (show PIDs for video and audio).

Maybe this is a problem of tsMuxeR

Richard1485
22nd June 2017, 14:56
Try muxing with EasyBD Lite (http://www.dvd-logic.com/easybd/) instead of tsMuxeR.

MrVideo
4th July 2017, 07:36
I've done a lot more digging into DDPlus and I've decided to abandon it. Why? Simply because it is not meant for 5.1 channels, but for having 7.1 channels. I wanted to use it do go from 640kbps to 1280kbps, but the 5.1 core can't go any higher than 640kbps.

Frankly, I do not know how any encoder can get away with just having 5.1, instead of 7.1. Yet streaming services are providing DD+ with only 5.1.

I'm confused. But, not to the point of digging into it any further. At least not for doing encoding.

What I'd like to be able to do now is that when I run across DD+, I'd like to know how to extract the 5.1 core and turn it into simple old DD 5.1, without recoding.

Thanks to those who have responded.

nevcairiel
4th July 2017, 09:50
I wanted to use it do go from 640kbps to 1280kbps, but the 5.1 core can't go any higher than 640kbps

This is wrong. If you use an independent substream as the base of the eac3 encode you can use up to 6.144Mbps. You just cannot use a legacy substream, which is basically just plain ac3. Perhaps whatever encoder you're using is not very good if it doesn't allow this.
The ffmpeg encoder definitely allows the higher bandwidth encodes. You just have to be aware that this is not a Blu-ray compatible eac3 encode.

Additionally to allowing more bandwidth, eac3 also has additional coding tools that result in a more effective encode, ie. more quality for the same bits.

MrVideo
4th July 2017, 10:03
Perhaps whatever encoder you're using is not very good if it doesn't allow this.
The ffmpeg encoder definitely allows the higher bandwidth encodes. You just have to be aware that this is not a Blu-ray compatible eac3 encode.
It was the ffmpeg encoder, as indicated in my initial posts.

The Dolby Labs left a lot out of the paper I read about DD+. I guess they were being specific to Blu-ray, without coming out and directly saying so.

MrVideo
4th July 2017, 10:09
I've learned a lot this morning (for me anyway) regarding EAC3. Between this thread and the eac3to thread, it has been a great learning experience.

Richard1485
4th July 2017, 14:04
What I'd like to be able to do now is that when I run across DD+, I'd like to know how to extract the 5.1 core and turn it into simple old DD 5.1, without recoding.

Obviously, the track that you recently posted about in the eac3to thread doesn't have such a core, but if you do find one that does, the explanation for how to extract it is given by tebasuna51 in this thread (https://forum.doom9.org/showthread.php?t=169776). The process is somewhat counterintuitive because of the .ec3 extension.

MrVideo
4th July 2017, 20:22
the explanation for how to extract it is given by tebasuna5
Yep, saw that posting.