Exemplo n.º 1
0
    def footer_partition_parse(self):
        """ Parse MXF footer partition. """

        # SMTPE 377M: Footer Partition Pack
        footer_partition_pack = MXFPartition(self.fd)
        footer_partition_pack.read()
        self.data['footer']['partition'] = footer_partition_pack

        key = InterchangeObject.get_key(self.fd)
        if key in ('060e2b34010101010201021001000000',
            '060e2b34010101010301021001000000'):
            # KLV Fill item
            klv = KLVFill(self.fd)
            klv.read()
            self.data['footer']['klvs'].append(klv)
Exemplo n.º 2
0
    def footer_extra_parse(self):

        # Read file's end
        key = InterchangeObject.get_key(self.fd)
        while key != '060e2b34020501010d01020101110100':

            if key in (
             '060e2b34010101010201021001000000',
             '060e2b34010101010301021001000000'
            ):
                # KLV Fill item
                klv = KLVFill(self.fd)
                klv.read()

            else:
                # 060e2b34025301010d01020101100100 -> Index Table Segment
                klv = KLVDarkComponent(self.fd)
                klv.read()
                print klv

            self.data['footer']['klvs'].append(klv)

            key = InterchangeObject.get_key(self.fd)

        # SMTPE 377M: Random Index Pack (optional after Footer Partition)
        if key != '060e2b34020501010d01020101110100':
            raise Exception('Invalid RandomIndexMetadata key: %s' % InterchangeObject.get_key(self.fd))
        random_index_pack = RandomIndexMetadata(self.fd)
        random_index_pack.read()
        self.data['footer']['klvs'].append(random_index_pack)
        self.data['footer']['random_index_pack'] = random_index_pack
Exemplo n.º 3
0
    def header_metadata_parse(self):

        dark = 0
        header_metadata_preface = None
        header_end = self.fd.tell() + self.data['header']['partition'].data['header_byte_count']

        while self.fd.tell() <= header_end:
            fd = self.fd
            key = InterchangeObject.get_key(self.fd)

            if key in ('060e2b34010101010201021001000000', \
                '060e2b34010101010301021001000000'):
                # KLV Fill item
                klv = KLVFill(fd)
                klv.read()

            elif key == '060e2b34020501010d01020101050100':
                # SMTPE 377M: Header Metadata (Primer Pack)
                #if not isinstance(header_klvs[-1], KLVFill) and \
                #    not isinstance(header_klvs[-1], MXFPartition):
                #    raise Exception('Error: MXFPrimer not located after Header Partition Pack')
                header_metadata_primer_pack = MXFPrimer(fd, debug=True)
                header_metadata_primer_pack.read()
                print header_metadata_primer_pack
                klv = header_metadata_primer_pack

            elif key == '060e2b34025301010d01010101012f00':
                # SMTPE 377M: Header Metadata (Preface)
                #if not isinstance(header_klvs[-1], KLVFill) and \
                #    not isinstance(header_klvs[-1], MXFPrimer):
                #    raise Exception('Error: MXFPrimer not located after Header Partition Pack')
                header_metadata_preface = MXFPreface(fd, header_metadata_primer_pack)
                header_metadata_preface.read()
                klv = header_metadata_preface

            elif key in (
             # essence descriptions (130~180)
             # SMPTE 377M: Strutural Metadata Sets
             '060e2b34025301010d01010101010900', # Filler

             '060e2b34025301010d01010101010f00', # Sequence

             '060e2b34025301010d01010101011100', # Source Clip
             '060e2b34025301010d01010101011400', # Timecode Component

             '060e2b34025301010d01010101011800', # ContentStorage

             '060e2b34025301010d01010101013000', # Identification
             '060e2b34025301010d01010101013700', # Source Package (File, Physical)
             '060e2b34025301010d01010101013600', # Material Package
             '060e2b34025301010d01010101013b00', # Timeline Track

             '060e2b34025301010d01010101012300', # EssenceContainerData
             '060e2b34025301010d01010101012800', # CDCI Essence Descriptor
             '060e2b34025301010d01010101014200', # GenericSoundEssenceDescriptor
             '060e2b34025301010d01010101014400', # MultipleDescriptor
             '060e2b34025301010d01010101014700', # AES3PCMDescriptor
             '060e2b34025301010d01010101014800', # WaveAudioDescriptor
             '060e2b34025301010d01010101015100', # MPEG2VideoDescriptor
             ):
                klv = MXFDataSet(fd, header_metadata_primer_pack)
                klv.read()

            else:
                klv = KLVDarkComponent(fd)
                klv.read()
                dark += 1

            self.data['header']['klvs'].append(klv)

        ### End of the parsing loop 1

        if self.debug:
            print "Loaded ", len(self.data['header']['klvs']), "KLVs", self.fd.tell()
            print "Skipped", dark, "dark KLVs"

        self.data['header'].update({
            'primer': header_metadata_primer_pack,
            'preface': header_metadata_preface,
        })
        return
Exemplo n.º 4
0
    def header_metadata_parse(self):

        dark = 0

        avid_metadata_preface = None
        header_metadata_preface = None
        header_end = self.fd.tell() + self.data['header']['partition'].data['header_byte_count']

        while self.fd.tell() < header_end:
            fd = self.fd
            key = InterchangeObject.get_key(self.fd)

            if key in ('060e2b34010101010201021001000000', \
                '060e2b34010101010301021001000000'):
                # KLV Fill item
                klv = KLVFill(fd)
                klv.read()

            elif key == '060e2b34020501010d01020101050100':
                # SMTPE 377M: Header Metadata (Primer Pack)
                #if not isinstance(header_klvs[-1], KLVFill) and \
                #    not isinstance(header_klvs[-1], MXFPartition):
                #    raise Exception('Error: MXFPrimer not located after Header Partition Pack')
                header_metadata_primer_pack = MXFPrimer(fd, debug=True)
                header_metadata_primer_pack.read()
                #print header_metadata_primer_pack
                klv = header_metadata_primer_pack
                #continue

            elif key == '060e2b34025301010d01010101012f00':
                # SMTPE 377M: Header Metadata (Preface)
                #if not isinstance(header_klvs[-1], KLVFill) and \
                #    not isinstance(header_klvs[-1], MXFPrimer):
                #    raise Exception('Error: MXFPrimer not located after Header Partition Pack')
                header_metadata_preface = MXFPreface(fd, header_metadata_primer_pack)
                header_metadata_preface.read()
                klv = header_metadata_preface

            elif key == '8053080036210804b3b398a51c9011d4':
                # Avid ???
                avid_metadata_preface = AvidMetadataPreface(fd, header_metadata_primer_pack)
                avid_metadata_preface.read()
                klv = avid_metadata_preface

            elif key in (
             # 416 chunk (dark)
             '060e2b34025301010d01010102010000',
             '060e2b34025301010d01010102020000',
             '060e2b34025301010d01010102040000',
             '060e2b34025301010d01010102050000',
             '060e2b34025301010d01010102060000',
             '060e2b34025301010d01010102070000',
             '060e2b34025301010d01010102080000',
             '060e2b34025301010d01010102090000',
             '060e2b34025301010d010101020a0000',
             '060e2b34025301010d010101020b0000',
             '060e2b34025301010d010101020c0000',
             '060e2b34025301010d010101020d0000',
             '060e2b34025301010d010101020e0000',

             '060e2b34025301010d01010102200000',
             '060e2b34025301010d01010102210000',
             '060e2b34025301010d01010102220000', # Dark Dictionary ?

             '060e2b34025301010d01010102250000',

             # 119 chunk: Metadata of type ???
             '060e2b34025301010d01010101011b00', # Dark Simple Type Definition
             '060e2b34025301010d01010101011f00', # Dark Derived Type Definition
             '060e2b34025301010d01010101012000', # Dark Concent Type Definition
             '060e2b34025301010d01010101012200', # Dark Links to Data/Container/Codecs definitions
            ):
                # Avid DataSet
                klv = AvidAAFDefinition(fd, header_metadata_primer_pack)
                klv.read()

            elif key in (
             # essence descriptions (130~180)
             # SMPTE 377M: Strutural Metadata Sets
             '060e2b34025301010d01010101010900', # Filler

             '060e2b34025301010d01010101010f00', # Sequence

             '060e2b34025301010d01010101011100', # Source Clip
             '060e2b34025301010d01010101011400', # Timecode Component

             '060e2b34025301010d01010101011800', # ContentStorage

             '060e2b34025301010d01010101012e00', # AVID

             '060e2b34025301010d01010101013700', # Source Package (File, Physical)

             '060e2b34025301010d01010101013b00', # Timeline Track

             '060e2b34025301010d01010101014200', # GenericSoundEssenceDescriptor
             '060e2b34025301010d01010101014400', # MultipleDescriptor
             '060e2b34025301010d01010101014800', # WaveAudioDescriptor
             ):
                klv = MXFDataSet(fd, header_metadata_primer_pack)
                klv.read()

            elif key in (
             '060e2b34025301010d01010101012800', # CDCI Essence Descriptor

             # avid does not use standard 10 bytes ProductVersion
             '060e2b34025301010d01010101013000', # Identification

             '060e2b34025301010d01010101013600', # Material Package
             '060e2b34025301010d01010101013f00', # AVID
            ):
                klv = AvidMXFDataSet(fd, header_metadata_primer_pack)
                klv.read()

            elif key == '9613b38a87348746f10296f056e04d2a':
                # Avid ObjectDirectory
                klv = AvidObjectDirectory(fd, True)
                klv.read()

            else:
                klv = KLVDarkComponent(fd)
                klv.read()
                dark += 1

            self.data['header']['klvs'].append(klv)

        ### End of the parsing loop 1

        if self.debug:
            print "Loaded ", len(self.data['header']['klvs']), "KLVs", self.fd.tell()
            print "Skipped", dark, "dark KLVs"

        self.data['header'].update({
            'primer': header_metadata_primer_pack,
            'preface': header_metadata_preface,
            'avid_preface': avid_metadata_preface,
        })
        return