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. Domains: forum.doom9.org / forum.doom9.net / forum.doom9.se |
|
|
#22 | Link |
|
Matroska find' ich toll
Join Date: Apr 2008
Posts: 1,413
|
Many thanks for this link and info.
Yes, for TrueHD is it more complex. The reason is the very short duration for TrueHD frames (1/1200). One frame alone is it really noticeable (a real question, no snark)? I don't know how many TrueHD frames are needed to be noticeable. In principle, the Blu-ray creators could have simply omitted the last few frames that follow the final video frame. But I suspect they consider several TrueHD frames together as a single "meaningful frame." That's why there are so many TrueHD frames. Okay, so we can say: there can be identical frames for TrueHD streams. I'll order the Blu-ray with my next movie order, because this looks very interesting. |
|
|
|
|
|
#23 | Link |
|
Registered Developer
![]() Join Date: Sep 2025
Location: Chi-town
Posts: 230
|
CARS_2 has 94 segments IIRC, or was it MONSTERS.
1/1200 * 94 = ~78ms People would not be wanting gaps correction with THD if it were not an issue. Even without identical frames there are issues, because each segment does not end cleanly with end of video and end of audio coinciding. As tebasuna pointed out, with a 32ms frame size, this quickly accumulates. The DG approach handles this with a single algorithm for all formats. The only difference is what you can cut without breaking the stream. For a player it doesn't matter, because the PTS timestamps can be used to qualify the playback across the seam. But when demuxing ES the timestamps are lost. Last edited by Columbo; 3rd March 2026 at 01:42. |
|
|
|
|
|
#24 | Link | ||||
|
Matroska find' ich toll
Join Date: Apr 2008
Posts: 1,413
|
Quote:
Quote:
Quote:
But this problem can be directly solved when creating an MKV file; or rather, it doesn't occur in the first place because the frames, audio, and video always retain their exact timestamps. Quote:
----------------- A general question about the algorithm for removing audio frames. Since you're familiar with this, could you perhaps confirm the following or correct me if necessary? At the end of each M2TS file, the algorithm surely checks how much excess audio has accumulated. If it reaches (or almost reaches) the duration of a video frame, an audio frame is discarded. I'd like to know which audio frame is discarded here: the one from the current M2TS file or the next one? After the audio frame is removed, it's still very unlikely that the audio and video will be exactly the same length. A small offset of 1ms to 10ms is certainly not uncommon. Let's say that an audio frame can be removed after the second M2TS file, and we cut the last audio frame from the current M2TS file. However, an offset of 4ms remains. This means that the first audio frame of the third m2ts file is no longer synchronized with the first video frame of the third m2ts file. All audio frames from the third m2ts file now have a 4ms offset to the video frames. Is this correct? |
||||
|
|
|
|
|
#25 | Link |
|
Registered Developer
![]() Join Date: Sep 2025
Location: Chi-town
Posts: 230
|
The accumulated video and audio times are maintained. When the audio excess passes the duration of 1/2 an audio frame, the audio stream is marked for needing a deletion. That causes the next audio frame to be deleted.
The cut will have made things such that the current state is that accumulated vid duration > audio duration, and the algorithm won't get triggered again until enough excess audio has again accumulated. Just like the Bresenham line drawing algorithm hugging the true line, the gaps algorithm hugs a desync of ~1/2 audio frame duration. It does not necessarily delete a frame at every gap but rather only when needed. In practice pathologies occur that make the audio excess larger than 1 frame so the algorithm allows for multiple frames to be deleted if needed. Of course, it's not "perfect" but it works well in practice. And it is applicable to all formats. domy's idea was to try to make things perfect. But it can't be perfect for various reasons, and if you try to salvage the idea, edge cases proliferate and make things quite complex. For example, audio content can be content "identical" but not bit identical (think of low-order bit differences). So now to detect duplicated content you need a fuzzy comparison of some kind, negating to some extent the idea of perfection. You can see by looking at the issues at his git (https://github.com/domyd/mlp/issues) that he abandoned trying to keep things working in the face of edge cases and pathologies, and stopped development. DG's algorithm is simple and robust and works well enough to be quite useful. We've been maintaining our tools since 2003. Improvements have been suggested and we're happy to consider them but so far nothing has been proposed that justifies the added complexity. One criticism that has been leveled is that if the video exceeds the audio at gaps then correction is never triggered, but for bluray we have never seen that in practice and it may be counter to the spec in any case. Now you have all our secrets! Watch me get fired. I understand that your method for MKV in effect retains the timestamps for things, which in conjunction with some mkvtoolnix magic and expected behavior of the players allows you to bypass the gaps problem. That is a creative approach, but doesn't work for demuxing ES, where timestamps are lost. You acknowledged that when you said: "There are issues and we need solutions. One for demuxing, and one for direct stream copy, write to MKV." I note that MKV is not the only target format, and that ES is often needed for other things than immediate playback. Last edited by Columbo; 3rd March 2026 at 02:00. |
|
|
|
|
|
#26 | Link | ||||
|
Matroska find' ich toll
Join Date: Apr 2008
Posts: 1,413
|
Quote:
I have one small comment about this. The Blu-ray specs state that a new m2ts file must always begin with a video and audio keyframe. Therefore, I'm wondering if it wouldn't be better NOT to delete the next audio frame, because it definitely/usually/should be a keyframe. Quote:
And I've also been dealing with this problem since 2002. It took me a lot of time to understand why the error occurs and where in the processing chain something is wrong. I never would have thought it was MTX that wasn't working optimally. It's not an MTX fault, but Mosu made a decision back then about how streams are appended. There's not much that can be done about that now. The DG-Team is so great!!! I'm happy that DGDemux exists! Quote:
One possibility would be to create a timestamp file during demuxing. This could then be reused whenever the audio stream needs to be processed. I don't think Rocky will fire you, he's a really nice guy. Quote:
Similarly, the players themselves don't really have any magic. VLC, for example, can't handle video gaps at all; the movie always freezes briefly, and video artifacts appear. The best players here are MPC-HC or mpv. The whole magic is just the timestamp file. You're absolutely right. I sometimes forget that there are other containers besides Matroska. For me, there's only Matroska, as it's the best container in the world. |
||||
|
|
|
|
|
#27 | Link | ||||||
|
Registered Developer
![]() Join Date: Sep 2025
Location: Chi-town
Posts: 230
|
Thank you for your reply.
Quote:
Quote:
Quote:
Quote:
Quote:
Quote:
|
||||||
|
|
|
|
|
#28 | Link | ||
|
Matroska find' ich toll
Join Date: Apr 2008
Posts: 1,413
|
Quote:
Quote:
Ordered chapters are already built into many players, not always well or optimally, but at least the basics are there. MPC-HC does all of this very well, and mpv is close behind. If you want to test some more Matroska features, you can try my mpvMatroska. |
||
|
|
|
|
|
#30 | Link |
|
Matroska find' ich toll
Join Date: Apr 2008
Posts: 1,413
|
Hi Columbo
Absolute yes. A single Edition is the same as multiple Editions. The different is only: the used m2ts files. But my cE not works with a single Edition in the Multi-Edition mode. To create the timestamp files manually is not really easy(almost impossible). In short: 1. the main timeline are the video frames 2. count the audio frames in each m2ts 3. the first audio frame of each m2ts gets the timestamp of the first video frame from the m2ts. |
|
|
|
|
|
#34 | Link |
|
Matroska find' ich toll
Join Date: Apr 2008
Posts: 1,413
|
To complicated, to less interested user.
I see my cE is able to create Timestamp files for single Editions, but it wont work for THD. I use a "fast" mode for TS-file creation, and THD breaks this small algo. As info: THD has two FPS values: 1/1200 for 48kHz; and 1/1102,5 for 44,1kHz I have no time currently to work on cE to fix that. But maybe future. |
|
|
|
|
|
#35 | Link |
|
Registered User
Join Date: Feb 2020
Posts: 595
|
The only one who handled it correctly is MakeMKV after 1.15.4 i was present during this all. https://forum.makemkv.com/forum/viewtopic.php?t=24048. It actually preserved first frame of next m2ts, which is a key frame (yes, TrueHD has key frames, ffmpeg had to implement key frames for mp4 container for TrueHD) and zeroed out the last subframe of previous segment. Also it is strange to say https://github.com/domyd/mlp/issues stopped development. He just archived the repo. That does not mean anything, the code is complete. There are no bugs there. It does almost the same thing as MakeMKV 1.15.4.
Last edited by Balling; 12th June 2026 at 01:48. |
|
|
|
|
|
#36 | Link | ||
|
Registered Developer
![]() Join Date: Sep 2025
Location: Chi-town
Posts: 230
|
That is false. The DG tools use the same approach, as does mlp, and in fact, as domy acknowledges, DG was the first to discover the correct way to cut frames from THD, and thereby create a solution to the sync issue. BTW, DG also created the first tool to merge THD and AC3 streams.
Quote:
Quote:
Finally, I remind you that making MKVs is not the only use case, that THD is not the only audio format, and that DG was the first to solve sync issues with seamless branching when demuxing. Last edited by Columbo; 12th June 2026 at 12:53. |
||
|
|
|
|
|
#37 | Link |
|
Registered User
Join Date: Feb 2020
Posts: 595
|
"There are 5 open issues, two of which are feature requests and 3 real issues. If you choose to not call the issues 'bugs' so you can ignore them, that's just word games."
Those bugs are caused by more complex timestamps in mpeg-ts container. If you extract the thd files with ffmpeg first the issue is no longer there. See this: https://rationalqm.us/board/viewtopi...b6aa978acac80a This feature request is a bad idea https://github.com/domyd/mlp/issues/12 because interleaved THD+AC3 files cannot be played by ffmpeg, it was specifically considered unacceptable format by ffmpeg. But to be fair ffmpeg is not a good m2ts blu-ray writer anyways. "I've read, DGDemux only removes the last minor from a previous segment if the next segment starts with 2 major sync frames" Oh, nice, this is what MakeMKV does. There is still an issue with ffmpeg warning that lossless check failed, right? Last edited by Balling; 12th June 2026 at 13:18. |
|
|
|
|
|
#38 | Link | ||||
|
Registered Developer
![]() Join Date: Sep 2025
Location: Chi-town
Posts: 230
|
Quote:
Quote:
Quote:
Quote:
Last edited by Columbo; 12th June 2026 at 13:38. |
||||
|
|
|
|
|
#39 | Link |
|
Registered User
Join Date: Feb 2020
Posts: 595
|
Except MakeMKV does not have problem on Knives out movie.
"I've investigated the Knives Out issue, and it seems that mlp indeed produces bad output for that disk (and presumably for all "please file issue" disks). The TrueHD streams are actually about 1000 samples shorter than the video segments, according to ffmpeg. But, MakeMKV somehow magically finds the missing audio (and it is legit, it's not just copied to fill the length or something) and gets a correct demux. So for now, until I get to the bottom of this, I'd suggest using MakeMKV for disks where it says "please file issue" at the end." https://github.com/domyd/mlp/issues/...ment-739534770 This is obfuscation on the Blu-ray disk itself. And it is hard to get it right. It is a bug in ffmpeg arguably which is used by mlp tool. M2TS parsers had other bugs like when timecode had 0x47 byte when that byte is used for sync, and no one considered M2TS specific header can contain 0x47 too, fixed in https://github.com/FFmpeg/FFmpeg/com...dc4b68d73fa7c7 Last edited by Balling; 12th June 2026 at 15:13. |
|
|
|
|
|
#40 | Link | |
|
Registered Developer
![]() Join Date: Sep 2025
Location: Chi-town
Posts: 230
|
Yes, Knives Out has obfuscation, but DGDemux handles it fine when you choose the correct MPLS, which is easy using the GUI. stevew wrote:
Quote:
I'm curious about what you are trying to accomplish here? Last edited by Columbo; 13th June 2026 at 12:14. |
|
|
|
|
![]() |
|
|