GabriellaChaos
19th January 2025, 03:32
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:
{
"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.
For example, I parsed the playlist in a mpls file into json below:
{
"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.