justdan96 / tsMuxer

tsMuxer is a transport stream muxer for remuxing/muxing elementary streams, EVO/VOB/MPG, MKV/MKA, MP4/MOV, TS, M2TS to TS to M2TS. Supported video codecs H.264/AVC, H.265/HEVC, VC-1, MPEG2. Supported audio codecs AAC, AC3 / E-AC3(DD+), DTS/ DTS-HD.
Apache License 2.0
876 stars 147 forks source link

Clipinf is not created correctly in some cases #700

Closed DreckSoft closed 1 year ago

DreckSoft commented 1 year ago

tsMuxeR seems to create an invalid / incomplete clipinf in some cases.

I've attached the original CLPI and the one created by tsMuxeR. Clipinf.zip 100MB of the TS file: https://anonfiles.com/Ndb6Sdibzd/00000_1_m2ts

The video file seems to be 1080i50, so kinda uncommon.

I also tried putting it in a MKV before remuxing but it won't help.

I also tried the old 1.10.6 version. It does also not work.

DreckSoft commented 1 year ago

I've re-uploaded the sample here: https://anonfiles.com/r5K5Ld58za/00000_1_m2ts

Is anyone looking into this?

DreckSoft commented 1 year ago

tsRemux does create a working CLPI if that helps... 00001.zip

Hellboy00000 commented 1 year ago

@DreckSoft You mentioned "So we have the first working UHD BD created using (almost) free tools (BDEdit is Donationware). The guide will be released as soon as we have a working nightly build and maybe another change to BDEdit which makes things more easy."

You shared the guide and where? Thanks.

DreckSoft commented 1 year ago

Sure I did: https://forum.doom9.org/showthread.php?t=184840 https://forum.videohelp.com/threads/409254-Creating-4k-UHD-Blu-Ray-Discs-%28With-Menu%29-With-%28Almost%29-Free-Software

jcdr428 commented 1 year ago

@DreckSoft seems to me that if (slice.bottom_field_flag == 1) return 0; on line 1082 of h264StreamReader.cpp should not be there. I've pushed the commit c2c4554 on the TryFix1 branch to verify.

Can you please try this tsMuxer.exe with various Blu-rays to see whether this fixes the issue without creating new ones ?

DreckSoft commented 1 year ago

@jcdr428

It aborts at 1,3% with "Reading buffer overflow. Possible container streams are not syncronized. Please, verify stream fps."

The original version will finish the mux (tried the most recent one) but still does not create a valid CLPI

It is the same result with the original M2TS and a remuxed MKV.

Here's a new sample: https://anonymfile.com/Eoe5/and-001.mkv

DreckSoft commented 1 year ago

If I ONLY mux the video, it'll go through AND creates a CLPI. CLPI will not be created (well the useless 1kb version will be) with the regular version. So it seems to be the right approach.

If I change the fps to 50 it'll also mux with all streams but the resulting file stutters (which kinda makes sense)

jcdr428 commented 1 year ago

Yes I think the problem does occur with interlaced h264 which pictures start with a bottom field macroblock -which is not so common and explains why it has remained undetected for so long. In which case, the I-frame is not logged for the CLPI EP map. I'll investigate further.

jcdr428 commented 1 year ago

@DreckSoft can you please try https://github.com/justdan96/tsMuxer/suites/16486836836/artifacts/942033210 ?

DreckSoft commented 1 year ago

It muxes without an error message, CLPI is created but the resulting video stream does not play correctly. However, the regular version will create a file that does not show ANY video.

However, your version has another issue:

Decoding DTS-HD stream (track 3): Bitrate: 1536Kbps  core + MLP data.Sample Rate: 48KHz  Channels: 5.1 (DTS Master Audio)
Decoding DTS-HD stream (track 4): Bitrate: 1536Kbps  core + MLP data.Sample Rate: 48KHz  Channels:  (DTS Master Audio)
Decoding DTS-HD stream (track 5): Bitrate: 1536Kbps  core + MLP data.Sample Rate: 48KHz  Channels:  (DTS Master Audio)

It'll show ASCI character 0002 instead of the number 2 for DTS-HD 2.0. The regular version does not have this issue.

DreckSoft commented 1 year ago

Ups sorry, I accidently hat the option "Always rebuild SEI and VUI data" enabled. Without that option, it creates a playable result but audio and subs are async to the video, however subs and audio are in sync (just not to the video). The regular version creates sync audio and subs but doesn't seek correctly and the picture is somewhat distorted.

DreckSoft commented 1 year ago

MediaInfo shows the file as 25.000fps. If i remux the M2TS to MKV, it'll show 51.958fps and is still async.

Could it be, that the stream is actually 25p but wrongly recognized as 50i at some point and therefore the framerate gets messed up?

jcdr428 commented 1 year ago

If you change if (slice.bottom_field_flag == 1) to == 0 on line 1082 of h264StreamReader.cpp, do you obtain a correct result with this Blu-ray ?

DreckSoft commented 1 year ago

As you removed the line I assume you mean in the master branch.

YES, that did fix it. The file is playable AND the CLPI is created. Thanks! But I assume that breaks TFF files?

jcdr428 commented 1 year ago

Yes that breaks TFF, that was just to confirm the issue. I have to find a way to detect whether I-frames are in top field frames or in bottom field frames as a precheck. Is it consistent throughout the whole sequence ? Do the used_for_reference frames always come first ?

jcdr428 commented 1 year ago

@DreckSoft can you please try https://github.com/justdan96/tsMuxer/suites/16508228053/artifacts/942942427 ?

DreckSoft commented 1 year ago

Works!

jcdr428 commented 1 year ago

Commit pushed to master, closing.