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.

 

Go Back   Doom9's Forum > Announcements and Chat > General Discussion

Reply
 
Thread Tools Search this Thread Display Modes
Old 19th January 2025, 03:32   #1  |  Link
GabriellaChaos
Registered User
 
Join Date: Oct 2021
Posts: 2
How to concat m2ts according to mpls?

I want to know how to correctly concatenate m2ts segments according to Intime/Outime specified in mpls playlist. I feel the Intime/Outtime fields in the mpls playitems might have unit in packets number, then how to seek to these package number in ffmpeg?

For example, I parsed the playlist in a mpls file into json below:

Code:
{
    "Length": 306,
    "NumberOfPlayItems": 2,
    "NumberOfSubPaths": 1,
    "PlayItems": [
        {
            "Length": 128,
            "ClipInformationFileName": "00002",
            "ClipCodecIdentifier": "M2TS",
            "MiscFlags1": 1,
            "IsMultiAngle": false,
            "RefToSTCID": 0,
            "INTime": 188955000,
            "OUTTime": 308939865,
            "UOMaskTable": 0,
            "MiscFlags2": 0,
            "StillMode": 0,
            "STNTable": {
                "Length": 94,
                "NumberOfPrimaryVideoStreamEntries": 1,
                "NumberOfPrimaryAudioStreamEntries": 2,
                "NumberOfPrimaryPGStreamEntries": 1,
                "NumberOfPrimaryIGStreamEntries": 1,
                "NumberOfSecondaryAudioStreamEntries": 0,
                "NumberOfSecondaryVideoStreamEntries": 0,
                "NumberOfSecondaryPGStreamEntries": 0,
                "PrimaryVideoStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1011"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 27,
                            "VideoFormat+FrameRate": 97
                        }
                    }
                ],
                "PrimaryAudioStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1100"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 131,
                            "AudioFormat+SampleRate": 97,
                            "LanguageCode": "jpn"
                        }
                    },
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1101"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 128,
                            "AudioFormat+SampleRate": 49,
                            "LanguageCode": "jpn"
                        }
                    }
                ],
                "PrimaryPGStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1200"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 144,
                            "LanguageCode": "jpn"
                        }
                    }
                ],
                "SecondaryPGStreamEntries": [],
                "PrimaryIGStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 2,
                            "RefToSubPathID": 0,
                            "RefToSubClipID": 0,
                            "RefToStreamPID": "0x1400"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 145,
                            "LanguageCode": "jpn"
                        }
                    }
                ],
                "SecondaryAudioStreamEntries": [],
                "SecondaryVideoStreamEntries": []
            }
        },
        {
            "Length": 128,
            "ClipInformationFileName": "00003",
            "ClipCodecIdentifier": "M2TS",
            "MiscFlags1": 1,
            "IsMultiAngle": false,
            "RefToSTCID": 0,
            "INTime": 189000000,
            "OUTTime": 189585585,
            "UOMaskTable": 582090251837636608,
            "MiscFlags2": 0,
            "StillMode": 0,
            "STNTable": {
                "Length": 94,
                "NumberOfPrimaryVideoStreamEntries": 1,
                "NumberOfPrimaryAudioStreamEntries": 2,
                "NumberOfPrimaryPGStreamEntries": 1,
                "NumberOfPrimaryIGStreamEntries": 1,
                "NumberOfSecondaryAudioStreamEntries": 0,
                "NumberOfSecondaryVideoStreamEntries": 0,
                "NumberOfSecondaryPGStreamEntries": 0,
                "PrimaryVideoStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1011"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 27,
                            "VideoFormat+FrameRate": 97
                        }
                    }
                ],
                "PrimaryAudioStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1100"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 131,
                            "AudioFormat+SampleRate": 97,
                            "LanguageCode": "jpn"
                        }
                    },
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1101"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 128,
                            "AudioFormat+SampleRate": 49,
                            "LanguageCode": "jpn"
                        }
                    }
                ],
                "PrimaryPGStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 1,
                            "RefToStreamPID": "0x1200"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 144,
                            "LanguageCode": "jpn"
                        }
                    }
                ],
                "SecondaryPGStreamEntries": [],
                "PrimaryIGStreamEntries": [
                    {
                        "StreamEntry": {
                            "Length": 9,
                            "StreamType": 2,
                            "RefToSubPathID": 0,
                            "RefToSubClipID": 0,
                            "RefToStreamPID": "0x1400"
                        },
                        "StreamAttributes": {
                            "Length": 5,
                            "StreamCodingType": 145,
                            "LanguageCode": "jpn"
                        }
                    }
                ],
                "SecondaryAudioStreamEntries": [],
                "SecondaryVideoStreamEntries": []
            }
        }
    ],
    "SubPaths": [
        {
            "Length": 36,
            "SubPathType": 3,
            "MiscFlags1": 0,
            "NumberOfSubPlayItems": 0,
            "SubPlayItems": []
        }
    ]
It references 2 m2ts files:
- 00002.m2ts from 188955000 to 308939865
- 00003.m2ts from 189000000 to 189585585

I would like to know what these integers mean, and how to concatenate these two segments into one m2ts (perhaps using ffmpeg or other tools). Appreciate your help!

Edit: I have to work with Linux(debian) cli tools, not tools with gui.

Last edited by GabriellaChaos; 19th January 2025 at 05:02. Reason: misspelling
GabriellaChaos is offline   Reply With Quote
Old 21st January 2025, 10:42   #2  |  Link
GabriellaChaos
Registered User
 
Join Date: Oct 2021
Posts: 2
I still have no idea about the unit. It seems like (308939865 - 188955000) / 45000 matches the duration of the 00002.m2ts in seconds. Maybe there is some kind of timebase information in the m2ts file?

Also, I mentioned that the IGStream with PID #0x1400 referenced in the mpls file does not exists in the list provided by ffprobe. What is IGStream? Why is it not in the m2ts file?
GabriellaChaos is offline   Reply With Quote
Old 21st January 2025, 21:42   #3  |  Link
Z2697
Registered User
 
Join Date: Aug 2024
Posts: 502
That unit is 45000

m2ts timebase is 1/90000, period.

https://github.com/SAPikachu/igstools
Z2697 is offline   Reply With Quote
Reply

Tags
bdmv, concatenate, ffmpeg, m2ts, mpls

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 23:50.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.