Log in

View Full Version : Editing AC3 header information...


rik1138
19th March 2011, 01:13
I found a couple of threads about this, but they all ended in discussions about why the question was asked, not if there was a way to do it... :cool:

Is there a tool out there that can edit the header of an AC3 file? I need to change the Dolby Prologic surround flags in a bunch of AC3 files, and was looking for a tool to allow me to do that (without re-encoding, just changing the header info...)

Being able to change all the settings would be nice (Bitstream mode, dial norm, input filtering, etc...), but the surround flag is an important one right now...

Any help?

I tried encoding the same file with and without Prologic too look at what has changed, but the flag that is changed is different on every 'frame' of audio apparently... Simple search&replace won't work.

tebasuna51
19th March 2011, 02:53
- Bitstream mode, for what?
- input filtering, to late the signal was already filtered.
- Dial Norm, you can use eac3to (or DN31-Ac3.exe attached).
- Set the DPL flag, you can use DplAc3.exe attached.

[EDIT]
New attachement here (https://forum.doom9.org/showthread.php?p=424067#post424067) including also SplitAc3 (https://forum.doom9.org/showthread.php?p=1447695#post1447695), DNx_eac3 (https://forum.doom9.org/showthread.php?p=1933603#post1933603) with sources and 64/32 bits versions.

The DNx_ac3 and DNx_eac3 are now DNx_Any and solving a bug detected in DNx_eac3

rik1138
19th March 2011, 04:06
- Bitstream mode, for what?
- input filtering, to late the signal was already filtered.
- Dial Norm, you can use eac3to (or DN31-Ac3.exe attached).
- Set the DPL flag, you can use DplAc3.exe attached.

Wasn't sure which of those settings actually do something to the audio file itself, or are just flags for the decoder to do stuff... (I.e., input filtering..)

Bitstream Mode, options are:
Complete Main
Music & Effects
Visually Impared
... Etc.

Not sure what they do actually, just one of the options in the encoder. :rolleyes: Never know when you might need to change something.

RF overmodulation, is that a 'flag', or does it actually change the audio during encoding? Something I'd like to be able to turn off without re-encoding, if that's an option.

Being able to change the prologic flags will be a huge help, thanks a lot for that! Will this allow changing between all 3 settings, or does it just turn PL on?

Thanks again, Rik

tebasuna51
19th March 2011, 04:35
To know about data en AC3 header read:
Digital Audio Compression Standard (AC-3, E-AC-3) Revision B (http://www.atsc.org/cms/index.php/standards/document-download/doc_download/13-a52b-digital-audio-compression-standard-ac-3-e-ac-3-revision-b)

DplAc3.exe turn PL on.

TDiTP_
19th March 2011, 10:02
Is there utility that can change DN to any value? Not only to -31dB.

And may be utility for change "Center mix level" and "Surround mix level":rolleyes:

tebasuna51
19th March 2011, 10:47
I don't know.

But you have the code, isn't difficult make the changes:
1) Read 1 frame
2) Change the value
3) Reconstruct crc1
4) Goto 1 until end of file

nickintheforest
16th April 2011, 07:01
Is there utility that can change DN to any value? Not only to -31dB.

ChangeDN (https://docs.google.com/folder/d/0B0rPtrLUrGhINjlkNzMzNjctNGM4My00MTk1LTg5ZWMtMTIyZWRiYTE0Yzgw/edit?pli=1&docId=0B0rPtrLUrGhIYjRlNzEyMmMtODA1Yi00Y2I4LTkyMzYtODEyYTM1M2ZiOTlm)
You may use change_dn.exe input.ac3 DN
where DN is integer of [0..31]
For testing this tool you may use test.exe (http://narod.yandex.ru/disk/9083677001/test.exe)
test.exe 1.ac3 27
FileSize : 315820288 bytes
SamplCod : 0 (2=32, 1=44.1, 0=48 KHz.)
BitRate : 448 Kb/s
FrameSize: 1792 bytes
DialNorm: -31db
0xXX
0xXX
First hex-value is byte (bytes) where is the information of DialNorm in first audio frame.
Second - other frames.
Of course, they must coincide.
If ac3 is mono then hex-values will be for example
3b 80
3b 80
DN bits are bits beginning 13 bit of BSI.
3B 80 = 00011101 10000000
11011 = 27

If 3/2 (L, C, R, SL, SR) или 3/1 (L, C, R, S)
DC
DC
DN bits are bits beginning 17 bit of BSI
0xDC = 11011100 (bin)
11011 = 27

Else DN bits are bits beginning 15 bit of BSI
с3 60
с3 60
с3 60 = 11000011 01100000
11011 = 27
--------
Russian forum (http://rutracker.org/forum/viewtopic.php?p=43832386#43832386)

tebasuna51, thanks for source.

Abradoks
13th January 2012, 17:55
Both links are dead now. Here is mirror: ChangeDN.7z

[Also dead]

Midzuki
13th January 2012, 18:16
Thanks! :thanks: :thanks: :thanks:

junh1024
14th January 2021, 12:20
Hi, is it possible to modify ChangeDN to work on E-AC3 files too?

E-AC3 Specification (https://www.etsi.org/deliver/etsi_ts/102300_102399/102366/01.04.01_60/ts_102366v010401p.pdf)


Sample E-AC3 file (https://cdn.discordapp.com/attachments/380573049893814272/799235667129139200/0-GVR-16ch.ec3)

Currently, the tool gives a crc1 error.

tebasuna51
16th January 2021, 19:46
@junh1024
This one work with your sample:

[EDIT]DNx_eac3.exe and DNx_ac3.exe included in AC3Util.7z in the second post (https://forum.doom9.org/showthread.php?p=1485920#post1485920)

junh1024
17th January 2021, 11:05
Thank you tebasuna51, it seems to work on EC3 files of other bitrates :). Can I upload the sources & binaries from this thread to Github as a backup?

PS: The EC3 is actually EC3 Atmos, so hopefully they still work on AVR.

tebasuna51
17th January 2021, 19:23
Can I upload the sources & binaries from this thread to Github as a backup?

All are simple free soft.

tebasuna51
3rd October 2021, 13:11
Thank you tebasuna51, it seems to work on EC3 files of other bitrates :). Can I upload the sources & binaries from this thread to Github as a backup?

PS: The EC3 is actually EC3 Atmos, so hopefully they still work on AVR.

Do you upload them to Github?
Because the eac3 management was buggy, the new one DNx_Any (https://forum.doom9.org/showthread.php?p=424067#post424067) work now for AC3 or EAC3.

But I can confirm the MKVToolNix issue (https://gitlab.com/mbunkus/mkvtoolnix/-/issues/3140), even with the CRC correct in my new version, my AVR (Denon) can't play like Atmos the modified EAC3.

I have a EAC3 Atmos with DN -14 tha play at very low volume, changed to DN -31 play at high volume but not like Atmos, changed one more time to -14 my AVR play like Atmos again.

aron7awol
22nd November 2024, 17:48
I have some files that I think will help a lot to diagnose the issue where Atmos decoding is broken when dialnorm is changed.

I encoded 1s of silence in all channels to EAC3 Atmos.

16chsilence1s DDP27.eac3.txt - Encoded with -27dB dialnorm, Atmos decoding works fine.
16chsilence1s DDP31.eac3.txt - Encoded with -31dB dialnorm, Atmos decoding works fine.
16chsilence1s DDP27 rem DNx.eac3.txt - Dialnorm removed from the DDP27 file using DNx_Any, Atmos decoding is broken.

The result of removing dialnorm from the DDP27 file should be the same as the DDP31 file, but it's not. Does comparing these files show you what the issue is and how to fix it?

tebasuna51
23rd November 2024, 12:35
Thanks for the samples.

The differences between DDP27.eac3 and DDP27 rem DNx are show in first image:
1) The DN value in byte 5 of header (86/87)
2) The CRC value at end of frame, the last two bytes before the next header at C00 position
The same for the rest of 32 frames.

The differences between DDP27 rem DNx and DDP31 are show in second image:
1) At position 55F there are 5 bytes differents and I don't know what it is.
2) The CRC value at end of frame is different for this 5 bytes (you can see the header value 87 for DB -31)
All the same for the rest of 32 frames.

Sorry but I don't know what are these 5 bytes, maybe Atmos metadata related to the DN value.

j7n
24th November 2024, 13:37
They are some kind of unknown checksum (32+8 bits) at the end of the embedded Atmos data, referred to as emdf_protection in the standard.

aron7awol
4th December 2024, 14:27
Ahh, too bad it’s not documented for Atmos.
https://www.etsi.org/deliver/etsi_ts/102300_102399/102366/01.04.01_60/ts_102366v010401p.pdf