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.

 

Go Back   Doom9's Forum > General > Audio encoding

Reply
 
Thread Tools Search this Thread Display Modes
Old 5th June 2022, 19:29   #1  |  Link
pcroland
Registered User
 
Join Date: Mar 2014
Location: Hungary
Posts: 115
deew (Dolby Encoding Engine Wrapper)


Dolby Encoding Engine Wrapper

deew: https://github.com/pcroland/deew
(Installation instructions on the github page.)
Code:
Description:
- handles Dolby's XML input fuckery in the background, giving you a proper CLI interface
- converts inputs to RF64 which DEE can use
  - bit depth, number of channels and other infos are parsed from the source
- an XML file will be generated for each input based on the settings
- the script utilizes thread pooling for batch encoding (see config)
- supports WSL path conversion for the Windows version of DEE (see config)
- in case of an invalid bitrate it will pick the closest allowed one
- automatic sample rate conversion using ffmpeg's soxr resampler in case of an unsupported sample rate
  - for DD/DDP/AC4 unsupported rates will be converted to 48 kHz
  - for TrueHD unsupported rates will be converted to 48 kHz if source sample rate is lower than 72 kHz, otherwise will be converted to 96 kHz
- automatic channel swapping for 7.1 sources (DEE swaps Ls Rs with Lrs Rrs for some reason)
- automatic dialnorm setting
- automatically compensates for DEE's 256 sample delay (DD and DDP encoding)
- checks if intermediate file is already created so you can encode different formats/bitrates using a single intermediate file, for example:
  "deew -f dd -b 448 -i input -k"
  "deew -f dd -b 640 -i input -k"
  "deew -f ddp -i input"
- works even with video inputs (first audio will be selected)
- fancy terminal output using rich
- versatile delay option that supports ms, s and also frame@fps formats
- parsing delay from filenames

Help:
> deew -h
deew 3.2.1

USAGE: deew [-h] [-v] [-i [INPUT ...]] [-ti INDEX] [-o DIRECTORY] [-f FORMAT]
            [-b BITRATE] [-dm CHANNELS] [-d DELAY] [-r DRC] [-dn DIALNORM]
            [-in INSTANCES] [-k] [-mo] [-fs] [-fb] [-lb] [-la] [-np] [-pl]
            [-cl] [-c] [-gc]

FLAGS:
  -h, --help                  show this help message.
  -v, --version               show version.
  -i, --input [INPUT ...]     audio file(s) or folder(s)
  -ti, --track-index INDEX    default: 0
                              select audio track index of input(s)
  -o, --output DIRECTORY      default: current directory
                              specifies output directory
  -f, --format FORMAT         options: dd / ddp / ac4 / thd
                              default: ddp
  -b, --bitrate BITRATE       options: run -lb/--list-bitrates
                              default: run -c/--config
  -dm, --downmix CHANNELS     options: 1 / 2 / 6
                              specifies downmix, only works for DD/DDP
                              DD will be automatically downmixed to 5.1 in case of a 7.1 source
  -d, --delay DELAY           examples: -5.1ms, +1,52s, -24@pal, +10@24000/1001
                              default: 0ms or parsed from filename
                              specifies delay as ms, s or frame@FPS
                              FPS can be a number, division or ntsc / pal
                              you have to specify negative values as -d=-0ms
  -r, --drc DRC               options: film_light / film_standard / music_light / music_standard / speech
                              default: music_light (this is the closest to the missing none preset)
                              specifies drc profile
  -dn, --dialnorm DIALNORM    options: between -31 and 0 (in case of 0 DEE's measurement will be used)
                              default: 0
                              applied dialnorm value between
  -in, --instances INSTANCES  examples: 1, 4, 50%
                              default: 50%
                              specifies how many encodes can run at the same time
                              50% means 4 on a cpu with 8 threads
                              one DEE can use 2 threads so 50% can utilize all threads
                              (this option overrides the config's number)
  -k, --keeptemp              keep temp files
  -mo, --measure-only         kills DEE when the dialnorm gets written to the progress bar
                              this option overrides format with ddp
  -fs, --force-standard       force standard profile for 7.1 DDP encoding (384-1024 kbps)
  -fb, --force-bluray         force bluray profile for 7.1 DDP encoding (768-1664 kbps)
  -lb, --list-bitrates        list bitrates that DEE can do for DD and DDP encoding
  -la, --long-argument        print ffmpeg and DEE arguments for each input
  -np, --no-prompt            disables prompt
  -pl, --print-logos          show all logo variants you can set in the config
  -cl, --changelog            show changelog
  -c, --config                show config and config location(s)
  -gc, --generate-config      generate a new config

Last edited by pcroland; 4th January 2024 at 13:49.
pcroland is offline   Reply With Quote
Old 22nd August 2022, 21:31   #2  |  Link
pcroland
Registered User
 
Join Date: Mar 2014
Location: Hungary
Posts: 115
Code:
deew 2.6.0:
- changed default DRC to music_light, which is closer to the missing
  none preset: https://forum.doom9.org/showpost.php?p=1972689&postcount=136
- fixed DRC option not being applied for stereo TrueHD encodes
- colorized argparse's help a little bit
- renamed -t/--threads to -in/--instances to be more accurate,
  since one DEE instance can use 2 threads. see -h for more info

deew 2.6.1:
- fixed typo in help

deew 2.6.2:
- added additional instance clamping for Windows DEE (6),
  it seems like you can't do more than 6 even on a 16 thread cpu

deew 2.7.0:
- fixed first metavar removal for argparse's --input
- fixed exception printing in threads
- use a Windows path by default under WSL
- temp path added to the summary
- better instructions on config error

deew 2.8.0:
- added summary_sections to config
- parsing delay from filenames too
__________________
deew (Dolby Encoding Engine Wrapper): deew.dev, Doom9 | substoforced
pcroland is offline   Reply With Quote
Old 23rd August 2022, 02:10   #3  |  Link
Blue_MiSfit
Derek Prestegard IRL
 
Blue_MiSfit's Avatar
 
Join Date: Nov 2003
Location: Los Angeles
Posts: 5,988
Very cool, I didn't think I'd see any other DEE users on doom9 since it's a pro tool
__________________
These are all my personal statements, not those of my employer :)
Blue_MiSfit is offline   Reply With Quote
Old 24th August 2022, 13:24   #4  |  Link
pcroland
Registered User
 
Join Date: Mar 2014
Location: Hungary
Posts: 115
Code:
deew 2.8.1:
- fixed version in tool itself

deew 2.8.2:
- removed m/p delay support and updated help to avoid confusion

deew 2.8.3:
- moved binary version parsing to another place to avoid error
  if binaries is set to false in config

deew 2.8.4:
- fixed unnecessary newlines in argparse

deew 2.8.5:
- fix spelling in override everywhere
- use custom pyinstaller build to avoid anti-viruses going crazy
__________________
deew (Dolby Encoding Engine Wrapper): deew.dev, Doom9 | substoforced
pcroland is offline   Reply With Quote
Old 25th August 2022, 22:17   #5  |  Link
pcroland
Registered User
 
Join Date: Mar 2014
Location: Hungary
Posts: 115
Code:
deew 2.9.2:
- added "-ti"/"--track-index"
- strip delay from output filenames
__________________
deew (Dolby Encoding Engine Wrapper): deew.dev, Doom9 | substoforced
pcroland is offline   Reply With Quote
Old 5th September 2022, 22:29   #6  |  Link
pcroland
Registered User
 
Join Date: Mar 2014
Location: Hungary
Posts: 115
Code:
deew 2.9.3:
- fixed spaces in paths
  ("quote" parameter was not working in "wpc()" if "is_wsl" was false)
__________________
deew (Dolby Encoding Engine Wrapper): deew.dev, Doom9 | substoforced
pcroland is offline   Reply With Quote
Old 9th September 2022, 16:07   #7  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Thanks, I test some encodes with:

deew -f ddp -k -la -dn -31 -np -b 448 -i input.wav
deew -f thd -k -la -dn -31 -np -i input.wav

Some tips:

-k (preserve intermediate files .xml and rf64 and next encode don't recreate them):
Code:
 Intermediate already exists && dee -x C:\Portable\0\temp/input.xml
to manually make changes in both files.
With 7.1 deew make always the remap between SL-SR <-> BL-BR with the fake channelmask (FL FR FC LF BL BR SL SR)
But if source is (FL FR FC LF SL SR TFL TFR) the remap is not necesary, see https://forum.doom9.org/showthread.p...64#post1963264
But DEE ignore the channelmask and output a eac3/thd stream (L R C LFE Ls Rs Rls Rrs) instead the correct (L R C LFE Ls Rs Vhl Vhr) like Audition 2017 can do and my AVR play fine.

-r none don't work (like you say):
Code:
ERROR: allowed DRC values: film_light, film_standard, music_light, music_standard, speech.
with Audition 2017 encoder work also.

- la (I don't see differences using it)

-dn -31 (like is the recommended value to override attenuation with decoders/players bad configurated) ask:
Code:
Consider leaving the dialnorm value at 0 (auto), setting it manually can be dangerous, are you sure you want to do it?
[y/n]:
-np (to cancel the previous ask)
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 10th September 2022 at 02:08. Reason: typo
tebasuna51 is offline   Reply With Quote
Old 9th September 2022, 21:23   #8  |  Link
pcroland
Registered User
 
Join Date: Mar 2014
Location: Hungary
Posts: 115
Quote:
Originally Posted by tebasuna51 View Post
-r none don't work (like you say)
I didn't say -r none works, DEE doesn't have a "none" preset and it's not listed in the --help either. If someone could implement DRC bit editing in Python it would be appreciated.
Quote:
Originally Posted by tebasuna51 View Post
-la (I don't see differences using it)
-la, --long-argument prints the ffmpeg and dee commands for each input with visible path names ("Intermediate already exists &&" means it skips the intermediate generation because there already is one), by default the ffmpeg and dee commands are printed with an "[input]" instead of the paths once (before that it lists the files where an intermediate file already exists)
Quote:
Originally Posted by tebasuna51 View Post
-dn -31 (like is the recommended value to override attenuation with decoders/players bad configurated) ask
-np (to cancel the previous ask)
I don't know what you mean.
__________________
deew (Dolby Encoding Engine Wrapper): deew.dev, Doom9 | substoforced
pcroland is offline   Reply With Quote
Old 10th September 2022, 01:51   #9  |  Link
tebasuna51
Moderator
 
tebasuna51's Avatar
 
Join Date: Feb 2005
Location: Spain
Posts: 6,890
Quote:
Originally Posted by pcroland View Post
...I don't know what you mean.
I only want expose the problems, not for your wrapper but for the DEE encoder itself.

I read the DEE docs and I don't know how select the NONE DRC preset or the (FL FR FC LF SL SR TFL TFR) channel map 3D 5.1.2, much more usefull than (L R C LFE Ls Rs Rls Rrs) only 2D sound 7.1, than can be emulated with 5.1 without differences.

By the moment the certified encoder in Audition 2017 is the best EAC3 encoder for me.
__________________
BeHappy, AviSynth audio transcoder.

Last edited by tebasuna51; 10th September 2022 at 02:07. Reason: typo
tebasuna51 is offline   Reply With Quote
Old 29th September 2022, 04:39   #10  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
Can you encode this 16 bit flac with TrueHD dolby encoder? I do not like how ffmpeg encoder produces quite horrible artifacts on my LG C9 HW decoder. I think it is a bug, even though it is lossless with our ffmpeg decoder.

The song has some quite crazy sounds. https://0x0.st/o4aU.%20%D0%9D%D0%B8%...BB%D0%B0%D0%B9

Does dolby encoder support mono? Can you reencode this? https://trac.ffmpeg.org/ticket/1726

You can use this: https://0x0.st/o9S0.flac

Last edited by tebasuna51; 29th September 2022 at 15:15. Reason: double post
Balling is offline   Reply With Quote
Old 29th September 2022, 05:26   #11  |  Link
filler56789
SuperVirus
 
filler56789's Avatar
 
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
Quote:
Originally Posted by Balling View Post
[Double post]I do not like how ffmpeg encoder produces quite horrible artifacts on my LG C9 HW decoder. I think it is a bug, even though it is lossless with our ffmpeg decoder.

The song has some quite crazy sounds. https://0x0.st/o4aU.%20%D0%9D%D0%B8%...BB%D0%B0%D0%B9
My guess is, the TrueHD firmware decoders expect THD streams encoded "in the Dolby way", so to speak.
F.W.I.W., the MLP/TrueHD encoder of ffmpeg has always generated files that are LARGER than the ones created by the old Surcode and the new Dolby compressors :-/
So I suppose that even though those files may be technically-correct or spec-compliant, this doesn't mean they will always be happily-accepted or correctly-decompressed by the ""certified"" decoders :-/

UPDATE: https://forum.doom9.org/showthread.p...68#post1975568
__________________
«Your software patents have expired.»

Last edited by filler56789; 29th September 2022 at 06:21. Reason: .
filler56789 is offline   Reply With Quote
Old 29th September 2022, 06:18   #12  |  Link
filler56789
SuperVirus
 
filler56789's Avatar
 
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
@Balling:

that FLAC is sampled at 44.1 kHz and maybe your device expects only 48 kHz (or higher) inputs

Did you resample it to 48 kHz before compressing to THD with ffmpeg?
__________________
«Your software patents have expired.»
filler56789 is offline   Reply With Quote
Old 29th September 2022, 06:31   #13  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
Quote:
Originally Posted by filler56789 View Post
@Balling:

that FLAC is sampled at 44.1 kHz and maybe your device expects only 48 kHz (or higher) inputs

Did you resample it to 48 kHz before compressing to THD with ffmpeg?
I did and I did not, both have artifacts. All stereo does. In fact I also tried more strange 176.4k and 192k. Just saying.
Balling is offline   Reply With Quote
Old 30th September 2022, 11:56   #14  |  Link
pcroland
Registered User
 
Join Date: Mar 2014
Location: Hungary
Posts: 115
Quote:
Originally Posted by Balling View Post
Can you encode this 16 bit flac with TrueHD dolby encoder?
https://envs.sh/QK0.thd
Quote:
Originally Posted by Balling View Post
Does dolby encoder support mono? Can you reencode this?
encode_to_dthd: Unsupported channel number: 1.
__________________
deew (Dolby Encoding Engine Wrapper): deew.dev, Doom9 | substoforced
pcroland is offline   Reply With Quote
Old 30th September 2022, 12:36   #15  |  Link
SeeMoreDigital
Life's clearer in 4K UHD
 
SeeMoreDigital's Avatar
 
Join Date: Jun 2003
Location: Notts, UK
Posts: 12,219
Quote:
Originally Posted by pcroland View Post


Why?
__________________
| I've been testing hardware media playback devices and software A/V encoders and decoders since 2001 | My Network Layout & A/V Gear |

Last edited by SeeMoreDigital; 30th September 2022 at 12:39.
SeeMoreDigital is offline   Reply With Quote
Old 30th September 2022, 13:33   #16  |  Link
filler56789
SuperVirus
 
filler56789's Avatar
 
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
Quote:
Originally Posted by SeeMoreDigital View Post
Why?
Speaking in general, it seems the DLLs and EXEs of Dolby's Encoding ""Engine"" suck by design :-/

F.W.I.W: adding the line "<custom_dialnorm>-31</custom_dialnorm>" to the XML configuration file apparently avoids the undesired dialnorm thing.
Still, no way to set the DRC value to "none".
__________________
«Your software patents have expired.»
filler56789 is offline   Reply With Quote
Old 30th September 2022, 14:16   #17  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
Quote:
Originally Posted by filler56789 View Post
Speaking in general, it seems the DLLs and EXEs of Dolby's Encoding ""Engine"" suck by design :-/

F.W.I.W: adding the line "<custom_dialnorm>-31</custom_dialnorm>" to the XML configuration file apparently avoids the undesired dialnorm thing.
Still, no way to set the DRC value to "none".
Please encode that too, I want 48k flac too since it was converted beforehand. I can confirm there are no artefacts on this normalised thd.

Compare to this, encoded with ffmpeg, the artefacts start as soon as chorus starts on 0:01:02 and do not happen if you decode with PC, only when lavfilter bitstreams: https://0x0.st/o4Vg.%20%D0%9D%D0%B8%...BB%D0%B0%D0%B9

What is also strange is that this thd is two times smaller. And reencoding your file is bigger, so I suppose it dithers to 24 bit. And yes, reencoding still produces artefacts while bitstreaming, so BUG IN FFMPEG (or LG people never tested no normalisation metadata file).

Last edited by Balling; 30th September 2022 at 14:27.
Balling is offline   Reply With Quote
Old 30th September 2022, 16:31   #18  |  Link
filler56789
SuperVirus
 
filler56789's Avatar
 
Join Date: Jun 2012
Location: Antarctic Japan
Posts: 1,351
@Balling:

https://www.mediafire.com/file/53xvp...kolai.rar/file

The archive contains both the "raw" THD stream and a conveniently-indexed MKA file.

eac3to says only "TrueHD, 2.0 channels, 48kHz",
so I presume the file has no dialog normalization actually :-|
__________________
«Your software patents have expired.»

Last edited by filler56789; 30th September 2022 at 16:33. Reason: clarity
filler56789 is offline   Reply With Quote
Old 1st October 2022, 18:12   #19  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
Yeah, I found Dolby Encoding Engine on the Internet. LOL. Yes, it does not artefact either and is correctly 16 bit out of all 24 being encoded always in TrueHD.
Balling is offline   Reply With Quote
Old 2nd October 2022, 22:25   #20  |  Link
Balling
Registered User
 
Join Date: Feb 2020
Posts: 539
>so I presume the file has no dialog normalization actually :-|

Dialnorm MAY BE present, but it will be only applied in Plex decoder (again TrueHD decoder in ffmpeg does not support DRC) if Dolby media encoder was "DRC default on" ON AND if you do not set -31

Last edited by Balling; 2nd October 2022 at 23:04.
Balling is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:56.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.