Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
![]() |
#1 | Link |
Registered User
Join Date: Sep 2002
Location: Italy
Posts: 136
|
Encode to 7.1 eac3 for free and volume adjustment
I'm trying to find a way to encode to 7.1 eac3 using free tools, so I tryed to reorganize the info available in this thread https://forum.doom9.org/showthread.php?t=177346.
Note: for the analysis, I refer to the doc here: https://www.atsc.org/atsc-documents/...dard-12172012/ PROCEDURE DESCRIPTION (WINDOWS 10/11) - Go to Plex Website-->Download (up on the right)-->For Desktop - Choose Plex (NOT Plex Media Server) and download the .exe setup - That .exe is a self-extracting installer. You can install it but it is not mandatory. If you have 7zip, you can right-click on it and select "extract to folder..." - Make a new folder e.g. on Desktop and copy - Plex Transcoder.exe - avfilter-8.dll - avcodec-59.dll - avformat-59.dll - swresample-4.dll - swscale-6.dll - avutil-57.dll - libc++.dll - libunwind.dll - The old Plex folder is no longer needed. You can delete it after checking this procedure is ok - Rename Plex Transcoder.exe in Plex_Transcoder.exe, just to remove annoying spaces - Download from https://forum.doom9.org/showthread.php?t=177346&page=10 , Balling message of 13 September 2022, EasyAudioEncoder.exe and modify it, or download the already modified version from github (they only differs for those two bytes). Put it together with the other files. - Plex Transcoder is somewhat an old version of ffmpeg which can interact with eae to produce eac3 output. It is poor in decoding, so feed it with pcm stuff (wav or w64) - Create this .bat and launch it Code:
start easyaudioencoder timeout /t 2 Plex_Transcoder.exe -y -bitexact -i input71.w64 -c:a eac3_eae -eae_root . -bitexact output.eac3 rem close EasyAudioEncoder manually pause OUTPUT ANALYSIS Code:
General Complete name : .\output.eac3 Format : E-AC-3 Format/Info : Enhanced AC-3 Commercial name : Dolby Digital Plus File size : 1.34 MiB Duration : 11 s 8 ms Overall bit rate mode : Constant Overall bit rate : 1 024 kb/s Audio Format : E-AC-3 Format/Info : Enhanced AC-3 Commercial name : Dolby Digital Plus Duration : 11 s 8 ms Bit rate mode : Constant Bit rate : 1 024 kb/s Channel(s) : 8 channels / 6 channels Channel layout : L R C LFE Ls Rs Lb Rb / L R C LFE Ls Rs Sampling rate : 48.0 kHz Frame rate : 31.250 FPS (1536 SPF) Compression mode : Lossy Stream size : 1.34 MiB (100%) Service kind : Complete Main Dialog Normalization : -31 dB compr : -0.28 dB dialnorm_Average : -31 dB dialnorm_Minimum : -31 dB dialnorm_Maximum : -31 dB ReportBy : MediaInfoLib - v24.12 - The output file seems to be ok but a little low on volume, but more than 0.28dB. I can restore the volume via ffmpeg decoding to pcm with drc_scale 0. Is it fault of the compr field? Reading the forum, it seems to be a problem of the dee encoder too. - Checking for 0B 77 occurrence with an hex editor, it seems that there are two interleaved streams with fixed size frames. The first one is about 576kbps (2292 B/frame) and the second is 448kbps (1804 B/frames) For reference, here the first two packets Code:
0B 77 04 79 3F 67 FF E0 04 00 ... 00 00 00 03 A1 54 83 E1 0B 77 43 85 3A 67 FF F1 A0 00 ... 00 00 00 00 00 00 4C CA 0B 77 04 79 ... - It is worth trying to remove, or set to zero, the compr field? I could try to do that following Tebasuna scripts for adjusting DN. Has anybody tried it? - As a (very) long term goal I would like to create a 7.1 eac3 with 5.1 embedded ac3 from 7.1 input with backward compatibility. Is there any reference and examples on how to do that practically? I've seen that you can specify mix option in the secondary stream. Last edited by hellgauss; 21st March 2025 at 10:07. |
![]() |
![]() |
![]() |
#2 | Link | |
Registered User
Join Date: Jan 2025
Posts: 53
|
Quote:
![]() https://forum.doom9.org/showthread.p...16#post1997616
__________________
Main Systems:- Threadripper 7970X on Asus Pro WS TRX50-Sage WiFi Ryzen 9 9950X3D on MSI Carbon X670E Ryzen 9 7950X on Gigabyte Aorus Elite B650 Intel 13900KF on MSI Tomahawk B660 |
|
![]() |
![]() |
![]() |
#3 | Link |
Registered User
Join Date: Sep 2002
Location: Italy
Posts: 136
|
Thanks for you answer, did not know that. It seems that he is using the same method. However Plex installation is not needed, and you can keep only a few files.
https://github.com/R3S3t9999/DoVi_Sc...20INSTALLATION |
![]() |
![]() |
![]() |
#4 | Link | ||
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
Thanks, the DoVi method don't work for me at all, with your method I need extract also:
libssl-3-x64.dll libcrypto-3-x64.dll libwinpthread-1.dll And now work fine (with some errors like you say) The output info is: Code:
File: C:\Portablz\Eac3Plex\output.eac3 Size: 2691072 bytes ----------------------------------------- First Frame Info StrmTyp .....................: 0 (0=Ind, 1=Dep, 2=AC3) SubStreamID .................: 0 FrameSize....................: 2292 bytes (573 Kb/s) SampleRate ..................: 0 (48000 Hz) NumBlksCod ..................: 3 (6 Blocks) Audio coding mode (acmod) ...: 7 (3/2 - L, C, R, SL, SR) Low frequency effects channel: 1 (Present) Version (bsid) ..............: 12 (Other sintax) Dialogue normalization ......: -31 dB Dynamic Range gain ..........: -0.27 dB Mixing metadata .............: 0 (Not exist) Informational metadata ......: 0 (Not exist) Additional Bsi ..............: 0 (Not exist) ----------------------------------------- Revised EAC3 Info Dyn. Range min/max : -12.04/3.34 dB Frames Tot/Ind/AC3.: 1314 / 657 / 0 Bitrate average... : 1024 Kb/s Duration ..........: 21024 ms (0 h. 0 m. 21.024 s.) ------------------------------------------------- End Info Not exist AC3 frames then this eac3 is not compatible with BD specs. I don't know if the encoder admit some parameters to modify the encode. Also that encoder ignore the channelmask of the wav input (the actual ffmpeg encoder read it and preserve it to the output) and the output is 7.1 when the input is 5.1.2 (3D). So that encoder is usseless for me. [EDIT]From the Plex_Transcoder.exe -h encoder=eac3_eae : Code:
Encoder eac3_eae [EAE E-AC-3 encoder]: General capabilities: delay Threading capabilities: none Supported sample rates: 48000 Supported sample formats: flt s16 Supported channel layouts: 5.1(side) 7.1 eae_eac3_enc AVOptions: -eae_root <string> ED..A...... EAE root path (default "") -eae_prefix <string> ED..A...... EAE file prefix (default "frame-") -eae_batch_frames <int> ED..A...... EAE number of frames for each pass (from 0 to 1000) (default 0) -eae_max_files <int> ED..A...... EAE number of files on disk (from 1 to 4) (default 2) -downmix <channel_layout> ED..A...... Request a specific channel layout from the decoder don't show a error but still output standard 7.1 And seems we can't modify other parameters, the encoder always use eac3 core (never ac3 core like required by BD specs) and always DN -31 (the -dialnorm parameter is not accepted) then low volume is not a encoder but decoder problem. Also the bitrate is accepted but ignored: Quote:
[2] Read fine the desired bitrate but the output is always 1024 even if is not needed (Trailing 0's) like with my simple channel test. The same file encoded to flac by ffmpeg: Quote:
Last edited by tebasuna51; 21st March 2025 at 19:39. Reason: add info |
||
![]() |
![]() |
![]() |
#5 | Link |
Registered User
Join Date: Sep 2002
Location: Italy
Posts: 136
|
A fast reverse engineering on the two streams headers using hex editor and online hex-->bit converter (I hope I did not got misaligned)
Code:
Independent 00 strmtype 000 substreamid 10001111001 frmsize 00 fscod 11 numblkscod 111 acmod 1 lfeon 01100 bsid 11111 dialnorm 1 compre 11111111 compr [I need to change this to 00001111] 0 chanmape 0 mixmdate 0 infomdate 0 addbsie (47 bits) [data] Code:
Dependent 01 strmtype 000 substreamid 01110000101 frmsize 00 fscod 11 numblkscod 101 acmod ["complete" 7.1 eac3 is also redundant!] 0 lfeon 01100 bsid 11111 dialnorm 1 compre 11111111 compr 1 chanmape 0001 1010 0000 0000 chanmap [see Tab.E2.5, you need to change this] 0 mixmdate 0 infomdate 0 addbsie (63 bit) [data] I do not have time now for a bitwriter and crc, but it should not be difficult. Perhaps it can be done encoding two streams with ffmpeg and a cpp small program, without plex. And perhaps it can also be done for ac3+eac3 for blu-ray compatibility. |
![]() |
![]() |
![]() |
#7 | Link | |
Registered User
Join Date: Sep 2002
Location: Italy
Posts: 136
|
Quote:
In a far future I think I will try the ffmpeg road, at least with eac3+eac3, so that I can tune bitrate. Probably the independent 5.1 stream can be copy-pasted from ffmpeg. For the independent 4.0 output stream I will try the following way: 1) Insert 16 bit channel map 2) Change some flags (strmtype, chanmape, etc) 3) Increase frmsize by 1 (16 bit more, 0.5kbps more at 48khz) 4) Recalculate crc Other thing to do for the raw input to ffmpeg: - be careful with normalization and 5.1 downmix coefficients for independent stream - Guess channel order for the dependent stream |
|
![]() |
![]() |
![]() |
#8 | Link |
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
Please tell me if you are successful.
About the ChannelMask I can suply the same file encoded by Audition like FL+FR+FC+LFE+BL+BR+TFL+TFR and FL+FR+FC+LFE+BL+BR+SL+SR, if can help you. And encoded by DDE like core EAC3 (standard) and core AC3 (Bluray compliant). |
![]() |
![]() |
![]() |
#10 | Link |
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
They are not mine, I copied them from the old DelayCut by jsoto
Link for the samples: https://www.sendspace.com/file/jdu9yw Source FL+FR+FC+LFE+BL+BR+SL+SR 8w341_a3D.eac3 Audition like FL+FR+FC+LFE+BL+BR+TFL+TFR 8w341_an.eac3 Both Audition encodes have a delay of 5.333 ms -> 1 more frame 8w341_db.eac3 Dolby Encoder Engine like Bluray compliant (core Ac3) 8w341_dn.eac3 Dolby Encoder Engine standard (core EAC3) I can't use 'None' for DRC in DEE then I use 'music light', but DN -31 and bitrate 768 Kb/s (minimum for 7.1). In Audition I use the same parameters. |
![]() |
![]() |
![]() |
#11 | Link |
Registered User
Join Date: Sep 2002
Location: Italy
Posts: 136
|
Some minor updates:
1) It seems that compr field should not be set to 0x0F but to 0x00 (I'll do more test) 2) To customize output, the core stream can be left untouched. In the second dependent stream I have been able to set channel mask (standard 7.1, or whatever 5.1.2 etc...) , dialn=31, compr. Just replace the bits (without adding any field) and recalculate crc. There are also 6 values of dynrng which change the volume. They are difficult to parse since they are in the middle of audio blocks. 3) Most interestingly, the independent core stream can be replaced with a different bitrate and different engine (e.g. ffmpeg). It can be even ac3 for blu-ray compliance. 4) The road to hack ffmpeg and change some headers seems not to be feasible. The coding algorithm has some differences for independent vs dependent stream. ffmpeg has no options to set the eac3 coding as "dependent". I'll reorganize my code into an usable script, which can mux/demux independent and dependent streams and set compr, chanmask and dialn. For dynrng setting it seems to be too difficult/time consuming. Stay tuned... |
![]() |
![]() |
![]() |
#12 | Link | ||||||
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
Quote:
The first four bits indicate gain changes in 6.02 dB, where (Table): 0000 => Gain 6.02 dB The following four bits (ABCD) indicate linear gain changes, where: ABCD => Gain 0.1ABCD (base 2) Then 0000 => Gain 0.10000 (base 2) = 1/2 = - 6.02 dB Then compr = 0000 0000 => 6.02 dB - 6.02 dB = 0 dB Quote:
Quote:
"The bit code of ‘0000 0000’ indicates 0 dB (unity) gain." Quote:
Quote:
Quote:
|
||||||
![]() |
![]() |
![]() |
#13 | Link |
Registered User
Join Date: Sep 2002
Location: Italy
Posts: 136
|
Here a first version of the script, probably buggy
![]() https://github.com/HG3112/md71 It is a little bit complicated to use at first sight, but there are some examples in the readme I have two questions: 1) Some years ago, perhaps, I read that there were some problems in muxing eac3 with ac3 core into .mkv container, e.g. with mkvmerge. Is this still an issue? I performed two test with mkv, one with 7.1 with ac3 core, the second as full .eac3 and get no problems on both on my tv. However I only have a 5.1 hardware. Is such stream playable if no DD+ support is available in the TV? 2) Assuming that channel 1-4 are untouched (coefficient=1.0) and that there is no overflow, what is the correct 7.1-->5.1 downmix coefficients for surround in a "basic" downmix? A) Here ( https://www.audiokinetic.com/en/libr...downmix_tables ) it is suggested Surround=1.0*side + 1.0*back B) My mathematical theory, which can be wrong, says Surround=0.707*side + 0.707*back C) ffmpeg default with -ac 6 is Surround=1.0*side + 0.707*back (???) D) Tebasuna ( https://forum.doom9.org/showthread.p...hlight=downmix ) suggests Surround=0.5*side + 0.5*back |
![]() |
![]() |
![]() |
#14 | Link | |
Life's clearer in 4K UHD
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,343
|
Quote:
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |
|
|
![]() |
![]() |
![]() |
#15 | Link |
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
Questions:
1) I don't read problems about the core AC3/EAC3, maybe about EAC3 with Atmos data. 2) A,B,C are wrong because Surround values must be in the range -1 to 1. To preserve the max volume without clip we need limit (and distort) only the peaks. See images in https://forum.doom9.org/showthread.p...41#post2017241 A downmix using ffmpeg can be: Code:
ffmpeg.exe -i input71.eac3 -filter_complex "asplit [f][s]; [f] pan=3.1|c0=c0|c1=c1|c2=c2|c3=c3 [r]; [s] pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7, compand=attacks=0:decays=0:points=-90/-84|-8/-2|-6/-1|-0/-0.1, aformat=channel_layouts=stereo [d]; [r][d] amerge [a]" -map "[a]" output51.ac3 |
![]() |
![]() |
![]() |
#16 | Link |
Registered User
Join Date: Apr 2006
Posts: 160
|
If you have four speakers in 7.1, they would be louder than two in 5.1. The most straightforward is to just add them together (A). I don't think it follows that you need to divide the level of side surround by 2 (B). Maybe the back speakers can be quieter by 3 dB to account for them being behind and to avoid widening the image too much (C).
Potential clipping shouldn't be addressed in the downmix matrix. There is usually ample headroom because surrounds typically have low level, and you can use a limiter if needed. |
![]() |
![]() |
![]() |
#17 | Link | |
Registered User
Join Date: Sep 2023
Location: NYC
Posts: 5
|
Quote:
![]() @hellgauss tried with a random eac3 file to change dialn and compr values and getting this error: ERROR: Unexpected EOF found in inputB Last edited by mannequin80; 5th April 2025 at 01:57. |
|
![]() |
![]() |
![]() |
#18 | Link | ||
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
Quote:
Quote:
1) First a mix at 50% to obtain normalized values: pan=stereo|c0=0.5*c4+0.5*c6|c1=0.5*c5+0.5*c7 Or (the same): pan=stereo|c0<c4+c6|c1<c5+c7 2) And after a gain of 2 for low levels and decrease the gain for high levels (see image) Code:
compand=attacks=0:decays=0:points=-90/-84|-8/-2|-6/-1|-0/-0.1 Last edited by tebasuna51; 5th April 2025 at 10:09. |
||
![]() |
![]() |
![]() |
#19 | Link | |
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
Quote:
With a 7.1 encoded with dde I do: md71 8w341_.eac3 : 8341_3D.eac3 : 31 00 1810 where 1810 hex = 1100000010000 bin = (table E2.5) Left Surround, Right Surround, Vhl/Vhr pair Seems work fine the changes but my 5.1.2 Denon play a mix of channels, I need to do more test. |
|
![]() |
![]() |
![]() |
#20 | Link | |
Moderator
![]() Join Date: Feb 2005
Location: Spain
Posts: 7,240
|
Quote:
md71 audiosphere.eac3 : audiosphere_.eac3 : 31 00 audiosphere.eac3 from https://www.demolandia.net/es/cine/t.../pagina-9.html And the: Code:
Dialogue normalization ......: -23 dB RF atenuattion ..............: 0.53 dB Code:
Dialogue normalization ......: -31 dB RF atenuattion ..............: 0.00 dB "They are some kind of unknown checksum (32+8 bits) at the end of the embedded Atmos data" |
|
![]() |
![]() |
![]() |
Tags |
eac3 |
Thread Tools | Search this Thread |
Display Modes | |
|
|