Log in

View Full Version : deew (Dolby Encoding Engine Wrapper)


pcroland
5th June 2022, 19:29
https://telegra.ph/file/e66f2d948015024ed148d.png
Dolby Encoding Engine Wrapper

deew: https://github.com/pcroland/deew
(Installation instructions on the github page.)
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
https://telegra.ph/file/efd2a1d3519bdf87fca03.gif

pcroland
22nd August 2022, 21:31
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

Blue_MiSfit
23rd August 2022, 02:10
Very cool, I didn't think I'd see any other DEE users on doom9 since it's a pro tool :)

pcroland
24th August 2022, 13:24
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

pcroland
25th August 2022, 22:17
deew 2.9.2:
- added "-ti"/"--track-index"
- strip delay from output filenames

pcroland
5th September 2022, 22:29
deew 2.9.3:
- fixed spaces in paths
("quote" parameter was not working in "wpc()" if "is_wsl" was false)

tebasuna51
9th September 2022, 16:07
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):
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.php?p=1963264#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):
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:
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)

pcroland
9th September 2022, 21:23
-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.
-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)
-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.

tebasuna51
10th September 2022, 01:51
...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.

Balling
29th September 2022, 04:39
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%D0%BA%D0%BE%D0%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

filler56789
29th September 2022, 05:26
[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%D0%BA%D0%BE%D0%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.php?p=1975568#post1975568

filler56789
29th September 2022, 06:18
@Balling:

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

Did you resample it to 48 kHz before compressing to THD with ffmpeg? :confused:

Balling
29th September 2022, 06:31
@Balling:

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

Did you resample it to 48 kHz before compressing to THD with ffmpeg? :confused:

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.

pcroland
30th September 2022, 11:56
Can you encode this 16 bit flac with TrueHD dolby encoder?
https://envs.sh/QK0.thd
Does dolby encoder support mono? Can you reencode this?
encode_to_dthd: Unsupported channel number: 1.

SeeMoreDigital
30th September 2022, 12:36
https://envs.sh/QK0.thd

https://i.imgur.com/WzmMRa0.png

Why?

filler56789
30th September 2022, 13:33
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".

Balling
30th September 2022, 14:16
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%D0%BA%D0%BE%D0%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).

filler56789
30th September 2022, 16:31
@Balling:

https://www.mediafire.com/file/53xvp604qm7c38e/o4aU-Nikolai.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 :-|

Balling
1st October 2022, 18:12
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
2nd October 2022, 22:25
>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

pcroland
3rd October 2022, 19:50
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".
It does not suck by design. If you encode series/movies you will get sane numbers. You only get these weird numbers with samples and other short stuff. It's the same ITU-R BS.1770-3 Loudness measurement that Adobe Audition would use.

filler56789
3rd October 2022, 23:07
It does not suck by design.

You don't get it.
(OR you just pretend that you don't :-/)

Dolby bought MLP from Meridian, ""upgraded"" MLP to TrueHD, but today dares to sell an encoder that DOES NOT DO everything the TrueHD format specification allows.

This is what I meant when I said that the DLLs and EXEs used by dee suck.

By the way... and now going off-topic...
please stop trying to ""correct"" me.
It didn't work on your GitHub and it will surely not work here on Doom9.
I rarely lie because I'm a terrible liar and I rarely am wrong because I normally know very-well what I talk about.😇

pcroland
4th October 2022, 00:59
I didn't correct you, I was stating facts. SeeMoreDigital asked why the dialnorm was measured at -9dB. Your reply suggested that the measurement implementation is not correct which it is. On GitHub you were saying bullshit like developers are narrow minded for not supporting OSes that reached their EOL (Win 7): https://github.com/pcroland/deew/issues/34

Balling
4th October 2022, 02:00
I didn't correct you, I was stating facts. SeeMoreDigital asked why the dialnorm was measured at -9dB. Your reply suggested that the measurement implementation is not correct which it is. On GitHub you were saying bullshit like developers are narrow minded for not supporting OSes that reached their EOL (Win 7): https://github.com/pcroland/deew/issues/34

I answered there. As people warn, DEE requires AVX2 instructions. So that is worse than Denuvo with SSE4.2 or 4.1. Also faster, of course. All AVX2 CPUs are able to run windows 11 even.

KSSW
7th October 2022, 05:20
I'll see what's new

tormento
9th October 2022, 23:53
As people warn, DEE requires AVX2 instructions.
Nope it doesn't. As I wrote previously, I use it with a i7-2600k.

filler56789
10th October 2022, 06:24
As people warn, DEE requires AVX2 instructions.

DEE ran fine on my jurassic Core2 Quad.
{{
And FWIW, the GUI of DME also works fine under Windows 7,
BUT its internal server requires Windows 8.1 (minimum).🤦
}}
Therefore what ""people"" said is not true.
Fortunately (and wisely) I turned off the notifications from pcroland's repository. :sly:

Balling
10th October 2022, 08:43
Okay then.

pcroland
14th October 2022, 22:12
Therefore what ""people"" said is not true.
Fortunately (and wisely) I turned off the notifications from pcroland's repository. :sly:
https://telegra.ph//file/3d00310380547228dd916.png
There was another comment saying it works without it, too bad you turned off notifications :'(

Balling
16th October 2022, 19:47
I did not turn off notifications.

tormento
2nd November 2022, 10:30
There is a strange behaviour of deew with two similar files. The first one is

Audio
Format : DTS ES XLL
Format/Info : Digital Theater Systems
Commercial name : DTS-HD Master Audio
Bit rate mode : Variable / Constant / Constant
Bit rate : Unknown / 1 509 kb/s / 1 509 kb/s
Channel(s) : 7 channels / 7 channels / 6 channels
Channel layout : C L R Ls Rs LFE Cb / C L R Ls Rs Cb LFE / C L R Ls Rs LFE
Sampling rate : 48.0 kHz
Frame rate : 93.750 FPS (512 SPF)
Bit depth : 16 bits
Compression mode : Lossless / Lossy / Lossy

while the other is

Audio
Format : DTS ES XXCH XLL
Format/Info : Digital Theater Systems
Commercial name : DTS-HD Master Audio
Bit rate mode : Variable / Constant / Constant
Bit rate : Unknown / 1 509 kb/s / 1 509 kb/s
Channel(s) : 7 channels / 7 channels / 6 channels
Channel layout : C L R Ls Rs LFE Cb / C L R Ls Rs Cb LFE / C L R Ls Rs LFE
Sampling rate : 48.0 kHz
Frame rate : 93.750 FPS (512 SPF)
Bit depth : 16 bits
Compression mode : Lossless / Lossy / Lossy

The first one is accepted by deew, while the second one gives me the error

ERROR: number of input channels can only be 1, 2, 6 or 8.

Any idea about why?

tebasuna51
2nd November 2022, 11:33
Because the first one is DTS ES XLL 6.1 matrixed: the Cb channel are mixed inside Ls Rs, don't exist like a independent channel. The file is decoded to 5.1 (even the MA) and supported by dee.

The second one is DTS ES XXCH XLL 6.1 discrete: the Cb channel exist like independent channel. The file is decoded to 6.1 (even the core) and it is not supported by dee.
Use Audition/TotalCode to EAC3 6.1 or down/up the 6.1 to 5.1/7.1 and dee

tormento
2nd November 2022, 12:18
Use Audition/TotalCode to EAC3 6.1 or down/up the 6.1 to 5.1/7.1 and dee
Now I see. Thanks. ;)

pcroland
2nd November 2022, 21:26
deew 2.9.4:
- allow new python version to be used

pcroland
25th November 2022, 00:51
deew 2.9.5:
- remove "-map 0:a:index" from "ffmpeg_args" if "-filter_complex" is present
somewhere in the command, so new ffmpeg versions can be used.

pcroland
22nd April 2023, 14:57
deew 3.0.0:
- added AC4 immersive stere support by MartinEesmaa
- add "dee_audio_filter_ac4_ims.dll" and "Object_0000.exe" from the AC4
zip to your DEE installation path and add "ac4_2_0 = 320" under the
"[default_bitrates]" section in your config file.
- mono input for TrueHD encoding error handling
- FLAC recommendation prompt for lossless mono/stereo encoding

pcroland
23rd April 2023, 11:38
deew 3.0.1:
- added ac4 to format error message
- fixed "allowed_bitrates" in "ac4_20"

pcroland
23rd December 2023, 19:36
deew 3.1.0:
- update "pyproject.toml" and "poetry.lock"

pcroland
27th December 2023, 00:35
deew 3.1.1:
- use custom PyInstaller for less virus flagging

pcroland
28th December 2023, 23:05
deew 3.1.2:
- fix "&" in filename by bpoxy

pcroland
29th December 2023, 00:23
deew 3.1.3:
- fix #37: Only show basename for already existing intermediate files

pcroland
2nd January 2024, 19:08
deew 3.2.0:
- add Windows 7 support with custom Python build:
https://github.com/adang1345/PythonWin7

pcroland
4th January 2024, 13:49
deew 3.2.1:
- handle "-master" in dee's version string

clidx
20th January 2024, 11:50
Has there been any progress on TrueHD to DDP Atmos transcoding?

guest
20th January 2024, 12:52
A GUI would be nice.

pcroland
25th February 2025, 22:28
deew 3.2.2:
- remove unnecessary thing for measure only
- try to fix temp delete