Add support for MMT/TLV container - #2647
Conversation
|
A follow-up round since the first review, still all from the clear signaling so it works on scrambled files:
|
|
More files have to be updated. You may refer to Generally only I also see that this is mostly implemented differently from a typical MediaInfo parser in that is does not use MediaInfo's Get/Skip and bitstream parsing functions beyond the header part so it will not produce a trace ( For example, this: void File_MmtTlv::Parse_Mmtp(const int8u* Data, size_t Size)
{
if (Size < 12)
return;
int8u b0 = Data[0];
bool packet_counter = (b0 >> 5) & 1;
bool extension_header = (b0 >> 1) & 1;
int8u payload_type = Data[1] & 0x3F;
const int8u* p = Data + 2;
size_t n = Size - 2;
// packet_id(16) + distribute_timestamp(32) + packet_sequence_number(32)
if (n < 10)
return;
int16u packet_id = RB16(p);should be something (may not be exactly like this, just example) like: void File_MmtTlv::Parse_Mmtp()
{
bool packet_counter, extension_header;
int8u payload_type;
int16u packet_id;
BS_Begin();
Skip_S1(2, "version");
Get_SB ( packet_counter, "packet_counter_flag");
Skip_S1(2, "FEC_type");
Skip_S1(1, "reserved");
Get_SB ( extension_header, "extension_flag");
Skip_SB( "RAP_flag");
Skip_S1(2, "reserved");
Get_S1 (6, payload_type, "payload_type");
BS_End();
Get_B2 (packet_id, "packet_id");I did not test but reading the codes, looks like parsing with HEVC and AAC parser may not work properly as well. |
|
Thank you for the important notes, I will do a review and maybe force-push a rewrite then. |
|
@saindriches thank you for your PR. Updated @cjee21 comments are good, please update the PR with that. |
MMT (MPEG Media Transport, ISO/IEC 23008-1) framed in TLV packets (ARIB STD-B32), the container used by Japanese ISDB-S3 BS/CS 4K/8K broadcasts. Maps the MPT asset list to HEVC, AAC and TTML streams; surfaces the present MH-EIT event as a Menu chapter (name, description, schedule), the MH-SDT service name, the video/audio component descriptors, and the scramble state. Everything comes from the clear signaling, so it also works on scrambled files. Structured like File_MpegTs: File_MmtTlv handles TLV, compressed-IP and MMTP framing plus fragment reassembly, then hands complete signaling tables to File_Mmt (tables) and File_Mmt_Descriptors (descriptors) via Open_Buffer, and creates a child ES parser per asset by asset_type. Parsing uses the standard Get_/Skip_/BS_ helpers throughout, so it produces a full trace. Signed-off-by: Rainbaby <rainbaby@outlook.jp>
Adds the MMT/TLV row (category Multiple, extension mmts, description) to Format.csv and the generated MediaInfo_Config_Automatic.cpp, so the format info and extensions come from the database rather than being filled by the parser. Signed-off-by: Rainbaby <rainbaby@outlook.jp>
Registers File_MmtTlv, File_Mmt and File_Mmt_Descriptors in Makefile.am, configure.ac (--disable-mmttlv, MEDIAINFO_MMTTLV_NO/_YES), the CMake feature list, the MSVC 2022 and 2026 projects (vcxproj, filters, UWP) and the Qt project. Signed-off-by: Rainbaby <rainbaby@outlook.jp>
|
I rewrote this to match the style, now squashed into three commits. Structurally it follows the MPEG-TS side: Tested on a lot of real captures, and CI is green including the minimal build. Happy to make any changes needed. |
|
I still see custom byte reading functions and some manual pointer (assigned from MediaInfo's Buffer) and size operations. Is this really needed and cannot be done with MediaInfo's built-in features? I am not sure about this but this seems incorrect. Open_Buffer_Init(&Desc);
Open_Buffer_Continue(&Desc, Buffer + Buffer_Offset + (size_t)Element_Offset, mpt_desc_len);
Open_Buffer_Finalize(&Desc);
Skip_XX(mpt_desc_len, "MPT_descriptors");And what is this Data/Size parameters and void casting that look useless? void File_MmtTlv::Parse_Mpu(int16u packet_id, int32u seq_num, const int8u* Data, size_t Size)
{
(void)Data; (void)Size; // parse at the element cursor (== Data/Size handed by Parse_Mmtp)Can consider using smart pointer for the audio/video parsers so that no need to manually delete and set to null. Since new and delete is at different places far apart, will also prevent mistakes in the future if that part is ever modified. This is from my quick look-through. I did not test or analyze in-depth. |
|
Thanks a lot for the review. I don't have deep experience with C++, this is helpful. In MMT the fragment boundaries are signaled in the MMTP header (the |
|
Another thing is init of variables can be done directly at the declaration in the header file instead of assigning in the constructor. |
Signed-off-by: Rainbaby <rainbaby@outlook.jp>
The forward scan could commit the present event and finalize before the first NTP/TOT arrived, so a recording that opens a few seconds before a program boundary froze on the outgoing program (e.g. a 1-minute PR spot) and missed the target program's assets. Leave the event uncommitted until a clock is in hand, so the boundary hop always runs and the scan cannot finalize early. Signed-off-by: Rainbaby <rainbaby@outlook.jp>
|
Just some minor things found by static analysis: This part does not look right to me from the offsets but since I don't really know about this format and what's happening there, let @JeromeMartinez comment when he reviews. I am not that good at handling fragments and conversions like handling removing HEVC AnnexB emulation prevention bytes or passing fragmented XMP from JPEG to XMP parser. Also Trace for AAC and some Data looks like they are outside MPU. |
Signed-off-by: Rainbaby <rainbaby@outlook.jp>
A fragmented NAL was reassembled and fed to the child at the last fragment's offset, so it was traced past the MPU the bytes came from. Feed each fragment as it arrives (FrameIsAlwaysComplete=false, MustAdaptSubOffsets=true) so it is traced where it lives. AAC keeps reassembling first, since its LOAS length header is only known once the whole unit is in hand. Signed-off-by: Rainbaby <rainbaby@outlook.jp>
The MPU line gave no hint what its payload was, so the child ES appeared with nothing tying it to a codec. Name it from the MPT asset_type (4CC plus codec, so an unmapped type still shows its 4CC), and spell out fragmentation_indicator. Trace only. Signed-off-by: Rainbaby <rainbaby@outlook.jp>
Adds a parser for MMT (ISO/IEC 23008-1) over TLV packets (ARIB STD-B32), the container used by Japanese ISDB-S3 4K/8K broadcasts. This covers what is currently needed to identify and inspect these files; further fields can follow as use cases arise.
Samples
This is my first contribution here, so please point out anything I have done wrong or should change.