Page 1 of 2

Slight difference in audio output delay

Posted: Sun Jun 05, 2022 5:28 pm
by Guest 2
I have a MKV file as follows:

Code: Select all

Audio #1
ID                             : 2
ID in the original source medi : 4352 (0x1100)
Format                         : DTS XLL
Format/Info                    : Digital Theater Systems
Commercial name                : DTS-HD Master Audio
Codec ID                       : A_DTS
Duration                       : 26 min 15 s
Bit rate mode                  : Variable / Constant
Bit rate                       : 3 638 kb/s / 1 509 kb/s
Channel(s)                     : 6 channels
Channel layout                 : C L R Ls Rs LFE
Sampling rate                  : 48.0 kHz
Frame rate                     : 93.750 FPS (512 SPF)
Bit depth                      : 24 bits
Compression mode               : Lossless / Lossy
Delay relative to video        : 42 ms
Stream size                    : 683 MiB (10%)
Language                       : Italian
Default                        : Yes
Forced                         : No
Original source medium         : Blu-ray

Audio #2
ID                             : 3
ID in the original source medi : 4353 (0x1101)
Format                         : DTS XLL
Format/Info                    : Digital Theater Systems
Commercial name                : DTS-HD Master Audio
Codec ID                       : A_DTS
Duration                       : 26 min 15 s
Bit rate mode                  : Variable / Constant
Bit rate                       : 2 031 kb/s / 1 509 kb/s
Channel(s)                     : 6 channels
Channel layout                 : 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
Delay relative to video        : 42 ms
Stream size                    : 381 MiB (6%)
Language                       : Japanese
Default                        : Yes
Forced                         : No
Original source medium         : Blu-ray
but when DGIndex demuxes it, the following audio files are produced:

Code: Select all

03 Una piccola ribellione_track2_ita_DELAY 9ms
03 Una piccola ribellione_track3_jpn_DELAY 9ms
Why?

Slight difference in audio output delay

Posted: Sun Jun 05, 2022 10:50 pm
by Bullwinkle
You'd have to give me a sample that does that.

Slight difference in audio output delay

Posted: Mon Jun 06, 2022 12:11 am
by Guest 2
Bullwinkle wrote:
Sun Jun 05, 2022 10:50 pm
You'd have to give me a sample that does that.
https://send.cm/d/BykZ.

Slight difference in audio output delay

Posted: Mon Jun 06, 2022 10:56 am
by Rocky
Thank you. Investigating by studying this:

https://www.matroska.org/technical/notes.html

Slight difference in audio output delay

Posted: Mon Jun 06, 2022 2:12 pm
by Guest 2
Rocky wrote:
Mon Jun 06, 2022 10:56 am
Thank you.
You are the most welcome.

I saw that gMKVExtractGUI shows an apparent and real delay.

Slight difference in audio output delay

Posted: Mon Jun 06, 2022 6:29 pm
by Rocky
gMKVExtractGUI does not work for me on my UHD display as required fields are obscured. What does it show for apparent and real?

Anyway, please try this and report back:

https://rationalqm.us/misc/DGIndexNV_test.zip

The MKV parser is very old moldy code that I got for free and which I do not want to have to get deep into. This is one of those expedient heuristic approaches. That means it seems to work but I'm not fully sure why. ;)

Slight difference in audio output delay

Posted: Tue Jun 07, 2022 2:53 am
by Guest 2
Rocky wrote:
Mon Jun 06, 2022 6:29 pm
gMKVExtractGUI does not work for me on my UHD display as required fields are obscured
Please report in author's thread. It's a very nice tool to use.
Rocky wrote:
Mon Jun 06, 2022 6:29 pm
What does it show for apparent and real?
In this specific case, it shows the same values. It happened, on other videos, to show different ones.
Image
Rocky wrote:
Mon Jun 06, 2022 6:29 pm
Anyway, please try this and report back
It seems to report the correct delay in the output file. I just need to understand if it's the real one or the apparent one. When you need a proper file to test, none comes handy.
Rocky wrote:
Mon Jun 06, 2022 6:29 pm
That means it seems to work but I'm not fully sure why. ;)
Perhaps you could use the same one that gMKVExtractGUI uses, i.e. MKVInfo and MKVExtract. Oh, an please show the stream delays in the demux panel, both apparent and real. Do not ask me how to find both. :mrgreen:

P.S: MKVTools adapt output language to the regional settings. Remember to use --ui-language switch if you want to keep it external.

Slight difference in audio output delay

Posted: Tue Jun 07, 2022 2:21 pm
by Rocky
OK, first re-download DGIndexNV_test.zip and run with that. And thank you for your valuable feedback.

I muxed a video ES and an audio ES with mkvtoolnix using different delay combos. Here are the combos and the delays put in the audio filename by DGIndexNV after save project:

[vid delay-aud delay in mkvtoolnix] [delay in demuxed filename]
0-0 0ms
0-100 100ms
100-0 -100ms
100-100 0ms
100-200 100ms
200-100 -100ms

Also:

03 Una piccola ribellione.mkv 42ms

These agree with gmkvextractgui 'effective' (relative to video) delays. Note that mkvtoolnix gets wonky with any entered negative delay value, because it assumes you are going to cut video or audio. Never use a negative value for mkvtoolnix -- there is always an equivalent with positive values, e.g., instead of entering an audio delay of -100, enter a video delay of 100, etc.

BTW, that "03 Una piccola ribellione.mkv" stream starts with an open GOP, which further complicates things. So you can't just get the first video timestamp for comparison, because frames are stored out of order in the MKV. And to complicate it even more, that stream is field coded. You know what, working on radios is much easier. Maybe even QM.

I'll report the sizing issue to gmkvextractgui but for now it works if I maximize it.

No need to use mkvinfo or mkvextract code. My parser is up to the job. Yeah, I know we use mkvextract to extract chapters, but that is because I am lazy and the parser code did not have that capability.

Showing delays in the demux panel will come later if at all. Currently that stuff is only looked at during save project.

I don't have any plans to show anything more than the effective (relative to video) delays, as that is what will be needed for transcoding or remuxing demuxed ES streams.

This works good for now but I am not done, as there are some weirdnesses I need to look into. Also have to be careful what I change to maintain correct working with DGSource(). Your feedback will be appreciated.

Slight difference in audio output delay

Posted: Tue Jun 07, 2022 2:35 pm
by Guest 2
Rocky wrote:
Tue Jun 07, 2022 2:21 pm
OK, first re-download DGIndexNV_test.zip and run with that.
What did you change?
Rocky wrote:
Tue Jun 07, 2022 2:21 pm
Your feedback will be appreciated.
As will always be your kindness and indefatigable efforts.

Slight difference in audio output delay

Posted: Tue Jun 07, 2022 2:36 pm
by Rocky
Ooh, a 50 cent word. My hat is off to you.

The change was to correctly handle delay combos with a non-zero video delay, e.g., 100-0.

And now I feel like gnawing a few acorns.

Slight difference in audio output delay

Posted: Thu Jun 23, 2022 10:26 am
by Rocky
I've got the new generation indexing completed (I hope). It all stemmed from this MKV delay issue that got me investigating. I found that the MKV support was a gigantic kludge and so decided to revamp it. That had implications outside the MKV code so it became a massive testing effort. Think about it:

For each combination of video type we have field/frame-based and open/closed GOP = 4 combos
We have 4 video types so we reach 4x4 = 16 combos.
We have 5 container types so we reach 5x16 = 80 combos
We have to check both DGIndexNV and DGDecodeNV, so we reach 2x80 = 160 testing combos.

Obviously I didn't test every combination but did test a large strategically sampled subset, coupled with a thorough code review.

So, I'm going to put out a release candidate probably today. The main things it will do are:

Fix GOP forward/backward stepping for MKV.
Fix delay calculation for MKV.
Add missing MKV compression support for DGSource (it was there for DGIndexNV, oops).
Fix some crashes with MP4.

But the main gain is for us, in terms of code understandability and maintainability. We can look at the code now and not say WTF!

Slight difference in audio output delay

Posted: Thu Jun 23, 2022 12:33 pm
by Guest 2
Rocky wrote:
Thu Jun 23, 2022 10:26 am
It all stemmed from this MKV delay issue that got me investigating.
Once I told you, I'll never let you get bored. Hat off for your investigation job.

Obviously the missing combination will be the bugged one. ;)
Rocky wrote:
Thu Jun 23, 2022 10:26 am
WTF
Tsk tsk tsk... One dollar fee for swearing in the jar. :mrgreen:

Slight difference in audio output delay

Posted: Thu Jun 23, 2022 2:12 pm
by Rocky
Stands for 'what the french toast'!

I'll put up a test version right now and reply back when it is up.

Slight difference in audio output delay

Posted: Thu Jun 23, 2022 2:18 pm
by Rocky
Here you go:

https://rationalqm.us/misc/DGDecNV_Guest 2.zip

Update both components and don't try to re-use existing DGI files.

Let's see how much stuff got broken. ;)

Time for my siesta.

Slight difference in audio output delay

Posted: Thu Jun 23, 2022 4:58 pm
by Guest 2
Rocky wrote:
Thu Jun 23, 2022 2:18 pm
Update both components and don't try to re-use existing DGI files.
Until a gate to hell won't open, it is ok.

Slight difference in audio output delay

Posted: Thu Jun 23, 2022 6:11 pm
by Rocky
You lost me on that one. I'm gonna assume you meant that the test build is OK (so far). Squirrels are not good at reading between the lines. We are very literal, if not very literate.

Slight difference in audio output delay

Posted: Fri Jun 24, 2022 4:24 am
by Guest 2
Rocky wrote:
Thu Jun 23, 2022 6:11 pm
I'm gonna assume you meant that the test build is OK (so far)
I have batch demuxed ~100 mkv files and the audio delays are consistent with the previous patched build.

I have found an issue with frame rendering when the mkv is cut from a seasonal BD with a single M2TS for multiple episodes.

It shows a green screen on the first frames, while the previous version behaves correctly.

Image

You can find two samples https://krakenfiles.com/view/kvUA5L1lW8/file.html and https://krakenfiles.com/view/j2GDXxsGbp/file.html.

To replicate issue, index them and open avs or vpy.

Slight difference in audio output delay

Posted: Fri Jun 24, 2022 6:56 am
by Rocky
Hmm, that's annoying. Shouldn't be too hard to fix though. Thank you for the testing and report.

Slight difference in audio output delay

Posted: Fri Jun 24, 2022 9:59 am
by Rocky
Please re-download and, as Sherman would say, report your success.

See? The code is so maintainable now that the bug was easy to find and fix. ;)

EDIT: Oops, give me a minute before downloading. I forgot to make the change for HEVC.

EDIT2: OK, good to go!

EDIT3: If you could test Vapoursynth that would be greatly appreciated.

Slight difference in audio output delay

Posted: Fri Jun 24, 2022 11:13 am
by Guest 2
Rocky wrote:
Fri Jun 24, 2022 9:59 am
report your success.
Seems to be working, great.

Now a whole night of encoding will find if the initial tests are right.

Slight difference in audio output delay

Posted: Fri Jun 24, 2022 12:25 pm
by Rocky
Cool, thank you.

I encoded Baywatch without issues. Well, there was one issue but not mine. Apparently x265.exe wants mod 8.

Also put Reverse() at the end of several scripts to test random access on every frame. No issues.

I might do chapter marks on the timeline next.

Slight difference in audio output delay

Posted: Fri Jun 24, 2022 1:46 pm
by Guest 2
Rocky wrote:
Fri Jun 24, 2022 12:25 pm
I might do chapter marks on the timeline next.
And episode split with proper audio, subs and chapters. :mrgreen:

Slight difference in audio output delay

Posted: Fri Jun 24, 2022 6:27 pm
by Rocky
First things first.

Slight difference in audio output delay

Posted: Sat Jun 25, 2022 2:48 pm
by Rocky
Please re-download for the next test version. It eliminates the need for mkvextract to extract chapters by doing it internally. The old MKV parser library previously did not parse chapters and that's why I used mkvextract. So I bit the bullet and added chapters parsing to the library. Gonna need it anyway to show chapters on the timeline for MKV.

https://rationalqm.us/misc/DGDecNV_Guest 2.zip

Whee!

Slight difference in audio output delay

Posted: Sun Jun 26, 2022 7:34 am
by Rocky
Please re-download again to get chapter marks on the timeline for MKV.

May add that for other containers in the future. Also, may support XML chapters file for the other containers. I'd like to get this version released first.