Facilities for ISO14496 files - the ISO Base Media File Format, the basis for several things including MP4 and MOV.
Project description
Facilities for ISO14496 files - the ISO Base Media File Format, the basis for several things including MP4 and MOV.
Latest release 20260531:
- BoxBody: provide a default boxes=() class attribute; drop HasBoxesMixin, already covered by BoxBody.getattr.
- Box.ancestor: raise ValueError if no matching ancestor is found.
- Box.BOX_TYPE: raise AttributeError if we cannot derive the type from the class name.
- Box.walk: yield (level,box,subboxes) 3-tuples to allow the called to track depth.
- MP4Command: rename cmd_parse to cmd_scan.
- BoxBody.iter: iterate self.boxes, not (), now that we always have a self.boxes.
- Box,BoxHeader: support for boxes with a UUID as the type.
- drop dump_box() in favour of new Box.dump_table and box.dump methods, add a recursion limit to Box.walk.
- Box: new .descendants() method to scan a Box hierarchy for boxes of specified types.
- MP4Command.cmd_scan: accept just one filename, following arguments are box types of interest.
- BoxBody.parse_field: accept ... in addition to an int to parse raw bytes.
- Drop OverBox.
- @boxbodyclass: decorator wrapping @binclass which reregisters the new class as the body handler for its box type.
- New FulBoxBody2 @binclass based class, hopefully will replace FullBoxBody in the fullness of time.
- Drop parse_fields(), obsoleted by Box.scan().
- Refactor the ILST box schemas as namedtuples.
- New ListOfBoxes(ListOfBinary,item_type=Box) class.
- Reimplement several box classes using @binclass.
- Box.box_type_s: ensure an ASCII box type is entirely printable (no control characters).
- ILSTBoxBody: make a SUBBOX_SCHEMA_BY_LONG_ATTRIBUTE to avoid a linear search in getattr.
- Box.parse: new body_type_for=None parameter for providing a custom box_type->BoxBody-class function, intended for the ILST subboxes.
- Drop the top level parse() function.
- Box: new .report_table() and .report() analogues for .dump_table() and .dump() but with human friendly summary information.
- Drop top level report() function, supplanted by Box.report_table() and Box.report().
- Box: new len returning the parsed length from .offset and .end_offset; new bool returning True to avoid implied call of len() for truthiness.
- Assorted other changes.
ISO make the standard available here:
Short summary:
add_body_subclass: Create and register a newBoxBodyclass that is simply a subclass of another. Return the new class.add_generic_sample_boxbody: Create and add a specific Time to Sample box - section 8.6.1.add_time_to_sample_boxbody: Add a Time to Sample box - section 8.6.1.Box: Base class for all boxes - ISO14496 section 4.2.BoxBody: The basis for allBoxbodies. This base class does not parse any of the body content.boxbodyclass: A decorator for@binclassstyleBoxBodysubclasses which reregisters the new binclass in theBoxBody.SUBCLASSES_BY_BOXTYPEmapping.BoxHeader: An ISO14496Boxheader packet.BTRTBoxBody: BitRateBoxBody - section 8.5.2.2.CO64BoxBody: A 'c064' Chunk Offset box - section 8.7.5.ContainerBoxBody: Common superclass of several things with.boxes.CPRTBoxBody: A 'cprt' Copyright box - section 8.10.2.CSLGBoxBody: A 'cslg' Composition to Decode box - section 8.6.1.4.decode_itunes_date_field: The iTunes 'Date' meta field: a year or an ISO timestamp.deref_box: Dereference a path with respect to this Box.DREFBoxBody: A 'dref' Data Reference box containing Data Entry boxes - section 8.7.2.1.ELNGBoxBody: AELNGBoxBodyis a Extended Language Tag box - ISO14496 section 8.4.6.ELSTBoxBody: An 'elst' Edit List FullBoxBody - section 8.6.6.EntryCountListOfBoxes: An intermediateFullBoxBodysubclass which contains more boxes whose number if specified with a leadingentry_countwhose defaut type isUInt32BE.FREEBoxBody: A 'free' or 'skip' box - ISO14496 section 8.1.2. Note the length and discard the data portion.FTYPBoxBody: An 'ftyp' File Type box - ISO14496 section 4.3. Decode the major_brand, minor_version and compatible_brands.FullBoxBody: A common extension of a basicBoxBody, with a version and flags field. ISO14496 section 4.2.FullBoxBody2: A common extension of a basicBoxBody, with a version and flags field. ISO14496 section 4.2.get_deref_path: Parse apathstring fromoffset. Return the path components and the offset where the parse stopped.HDLRBoxBody: A HDLRBoxBody is a Handler Reference box - ISO14496 section 8.4.3.ILSTAofBSchema: Attribute name and type for ILST "A of B" schema.ILSTBoxBody: Apple iTunes Information List, container for iTunes metadata fields.ILSTISOFormatSchema: Attribute name and type for ILST ISO format schema.ILSTRawSchema: Attribute name and type for ILST raw schema.ILSTTextSchema: Attribute name and type for ILST text schema.ILSTUInt32BESchema: Attribute name and type for ILSTUInt32BEschema.ILSTUInt8Schema: Attribute name and type for ILSTUInt8BEschema.itunes_media_type: itunes_media_type(type, stik)itunes_store_country_code: itunes_store_country_code(country_name, iso_3166_1_code, itunes_store_code)ListOfBoxes: AListOfBinarycontainingBoxes.main: Command line mode.MDATBoxBody: A Media Data Box - ISO14496 section 8.1.1.MDHDBoxBody: A MDHDBoxBody is a Media Header box - ISO14496 section 8.4.2.METABoxBody: A 'meta' Meta BoxBody - section 8.11.1.MOOVBoxBody: An 'moov' Movie box - ISO14496 section 8.2.1. Decode the contained boxes.MVHDBoxBody: An 'mvhd' Movie Header box - ISO14496 section 8.2.2.parse_tags: Parse the tags frompath. Yield(box,tags)for each subbox with tags.PDINBoxBody: A 'pdin' Progressive Download Information box - ISO14496 section 8.1.3.SMHDBoxBody: A 'smhd' Sound Media Headerbox - section 12.2.2.STCOBoxBody: A 'stco' Chunk Offset box - section 8.7.5.STDPBoxBody: ASTDPBoxBodyis a DegradationPriorityBox - ISO14496 section 8.5.3.2.STSCBoxBody: 'stsc' (Sample Table box - section 8.7.4.1.STSDBoxBody: ASTSDBoxBodyis a SampleDescriptionBoxBody - ISO14496 section 8.5.2.2.STSZBoxBody: A 'stsz' Sample Size box - section 8.7.3.2.STZ2BoxBody: A 'stz2' Compact Sample Size box - section 8.7.3.3.TimeStamp32: The 32 bit form of an ISO14496 timestamp.TimeStamp64: The 64 bit form of an ISO14496 timestamp.TimeStampMixin: Methods to assist with ISO14496 timestamps.TKHDBoxBody: A 'tkhd' Track Header box - ISO14496 section 8.2.2.TrackGroupTypeBoxBody: A TrackGroupTypeBoxBody contains a track group id - ISO14496 section 8.3.3.2.TrackReferenceTypeBoxBody: A TrackReferenceTypeBoxBody contains references to other tracks - ISO14496 section 8.3.3.2.TREFBoxBody: Track Reference BoxBody, container for trackReferenceTypeBoxes - ISO14496 section 8.3.3.TTSB_Sample: TTSB_Sample(count, delta).URL_BoxBody: An 'url ' Data Entry URL BoxBody - section 8.7.2.1.URN_BoxBody: An 'urn ' Data Entry URL BoxBody - section 8.7.2.1.UTF8or16Field: An ISO14496 UTF8 or UTF16 encoded string.VMHDBoxBody: A 'vmhd' Video Media Headerbox - section 12.1.2.
Module contents:
-
add_body_subclass(superclass, box_type, section, desc): Create and register a newBoxBodyclass that is simply a subclass of another. Return the new class. -
add_generic_sample_boxbody(box_type, section, desc, struct_format_v0, sample_fields, struct_format_v1=None, has_inferred_entry_count=False): Create and add a specific Time to Sample box - section 8.6.1. -
add_time_to_sample_boxbody(box_type, section, desc): Add a Time to Sample box - section 8.6.1. -
class Box(cs.binary.SimpleBinary): Base class for all boxes - ISO14496 section 4.2.This has the following fields:
header: aBoxHeaderbody: aBoxBodyinstance, usually a specific subclassunparsed: any unconsumed bytes from theBoxare stored as here
Box.BOX_TYPE:
The default .BOX_TYPE is inferred from the class name.
Box.__bool__(self):
A Box is always true, prevents implied call of len() for truthiness.
Box.__getattr__(self, attr):
If there is no direct attribute from SimpleBinary.__getattr__,
have a look in the .header and .body.
Box.__iter__(self):
Iterating over a Box iterates over its body.
Typically that would be the .body.boxes
but might be the samples if the body is a sample box,
etc.
Box.ancestor(self, box_type):
Return the closest ancestor box of type box_type.
Raise ValueError if there is no such ancestor.
Box.box_type:
The Box header type.
Box.box_type_path:
The type path to this Box.
Box.box_type_s:
The Box header type as a string.
If the header type is a UUID, return its str form.
Otherwise, if the header type bytes decode as ASCII, return that.
Otherwise the header bytes' repr().
Box.box_type_uuid:
The Box header type UUID for boxes whose box_type is b'uuid'.
Box.descendants(self, sub_box_types: Union[str, List]):
A generator to scan descendants of this box for boxes
matching sub_box_types.
The sub_box_types may be a dot separated string or a list.
Box.dump(self, file=None, **dump_table_kw):
Dump this Box to file (default sys.stdout per cs.lex.printt.
Other keyword paramaters are passed to Box.dump_table.
Box.dump_table(self, table=None, columns=('box_type', 'size', 'description'), dump_fields=False, dump_offsets=False, recurse=False) -> List[Tuple[str, str]]:
Dump this Box as a table of descriptions.
Return a list of (title,description) 2-lists
with fields and subboxes in tuples
suitable for use with cs.lex.printt().
Box.gather_metadata(self, prepath='') -> Iterable[Tuple[str, ForwardRef('Box'), cs.tagset.TagSet]]:
Walk the Box hierarchy looking for metadata.
Yield (box_path,Box,TagSet) 3-tuples for each Box
with a nonempty .metatags.
Box.merged_metadata(self) -> cs.tagset.TagSet:
Return a TagSet containing the merged metadata from this Box down.
Box.metatags(self) -> cs.tagset.TagSet:
Return a TagSet containing direct metadata for this box.
This default implementation returns an empty TagSet.
Box.parse(bfr: cs.buffer.CornuCopyBuffer, body_type_for=None):
Decode a Box from bfr and return it.
Box.parse_field(self, field_name, bfr: cs.buffer.CornuCopyBuffer, binary_cls):
parse_field delegates to the Box body parse_field.
Box.parse_length:
The length of the box as consumed from the buffer,
computed as self.end_offset-self.offset.
Box.reparse_buffer(self):
A context manager for continuing a Box parse from the unparsed field.
Pops the final unparsed field from the Box,
yields a CornuCopyBuffer made from it,
then pushes the unparsed field again
with the remaining contents of the buffer
after the reparse is done.
Box.report(self, file=None, **report_table_kw):
Report on this Box to file (default sys.stdout per cs.lex.printt.
Other keyword paramaters are passed to Box.report_table.
Box.report_table(self, table=None, indent='', subindent=' '):
Report some human friendly information as a table.
Return a list of (title,description) 2-tuples
suitable for use with cs.lex.printt().
Box.self_check(self):
Sanity check this Box.
Box.transcribe(self):
Transcribe the Box.
Before transcribing the data, we compute the total box_size from the lengths of the current header, body and unparsed components, then set the header length if that has changed. Since setting the header length can change its representation we compute the length again and abort if it isn't stable. Otherwise we proceeed with a regular transcription.
Box.unparsed_bs:
The unparsed data as a single bytes instance.
Box.user_type:
The header user_type.
Box.walk(self, *, level=0, limit=None) -> Iterable[Tuple[int, ForwardRef('Box'), List[ForwardRef('Box')]]]:
Walk this Box hierarchy.
Yield (level,self,subboxes) 3-tuples starting with the top box (self)
and recursing into its subboxes.
As with os.walk, the returned subboxes list
may be modified in place to prune or reorder the subsequent walk.
class BoxBody(cs.binary.SimpleBinary): The basis for allBoxbodies. This base class does not parse any of the body content.
BoxBody.__getattr__(self, attr):
The following virtual attributes are defined:
- TYPE
s: "boxes of type TYPE", an uppercased box type name with a trainings; a list of all elements whose.box_typeequals TYPE.lower().encode('ascii'). The elements are obtained by iterating overselfwhich normally means iterating over the.boxesattribute. - TYPE:
"the box of type TYPE",
an uppercased box type name;
the sole element whose box type matches the type,
obtained from
.TYPEs[0]with a requirement that there is exactly one match. - TYPE
0: "the optional box of type TYPE", an uppercased box type name with a trailing0; the sole element whose box type matches the type, obtained from.TYPEs[0]with a requirement that there is exactly zero or one match. If there are zero matches, returnNone. Otherwise return the matching box.
BoxBody.add_field(self, field_name, value):
Add a field named field_name with the specified value
to the box fields.
BoxBody.boxbody_type_from_class():
Compute the Box's 4 byte type field from the class name.
BoxBody.for_box_type(box_type: bytes):
Return the BoxBody subclass suitable for the box_type.
BoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Create a new instance and gather the Box body fields from bfr.
Subclasses implement a parse_fields method to parse additional fields.
BoxBody.parse_boxes(self, bfr: cs.buffer.CornuCopyBuffer, field_name='boxes', **box_scan_kw):
Utility method to parse the remainder of the buffer as a
sequence of Boxes and to save them as the attribute named by field_name<
default ".boxes".
BoxBody.parse_field(self, field_name, bfr: cs.buffer.CornuCopyBuffer, binary_cls):
Parse an instance of binary_cls from bfr
and store it as the attribute named field_name.
binary_cls may also be an int, in which case that many
bytes are read from bfr.
BoxBody.parse_field_value(self, field_name, bfr: cs.buffer.CornuCopyBuffer, binary_cls):
Parse a single value binary, store the value as field_name,
store the instance as the field field_name+'__Binary'
for transcription.
Note that this disassociates the plain value attribute from what gets transcribed.
BoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Parse additional fields.
This base class implementation consumes nothing.
BoxBody.transcribe(self):
Transcribe the binary structure.
This default implementation transcribes the fields parsed with the
parse_field method in the order parsed.
BoxBody.transcribe_fields(self):
Transcribe the fields parsed with the parse_field method in the
order parsed.
boxbodyclass(*da, **dkw): A decorator for@binclassstyleBoxBodysubclasses which reregisters the new binclass in theBoxBody.SUBCLASSES_BY_BOXTYPEmapping.class BoxHeader(cs.binary.BoxHeader): An ISO14496Boxheader packet.
BoxHeader.parse(bfr: cs.buffer.CornuCopyBuffer):
Decode a box header from bfr.
BTRTBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
BTRTBoxBody.__setattr__(self, attr, value):
Set a data field from value.
BTRTBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
BTRTBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
BTRTBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
BTRTBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
BTRTBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
BTRTBoxBody.transcribe(self):
Transcribe this instance.
CO64BoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the entry_count and chunk_offsets fields.
CO64BoxBody.transcribe(self):
Transcribe a CO64BoxBody.
class ContainerBoxBody(ContainerBoxBody__original): Common superclass of several things with.boxes.
ContainerBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
ContainerBoxBody.__setattr__(self, attr, value):
Set a data field from value.
ContainerBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
ContainerBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
ContainerBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
ContainerBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
ContainerBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
ContainerBoxBody.transcribe(self):
Transcribe this instance.
CPRTBoxBody.language:
The language_field as the 3 character ISO 639-2/T language code.
CSLGBoxBody.CSLGParamsLong
CSLGBoxBody.CSLGParamsQuad
CSLGBoxBody.__getattr__(self, attr):
Present the params attributes at the top level.
CSLGBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the compositionToDTSShift, leastDecodeToDisplayDelta, greatestDecodeToDisplayDelta, compositionStartTimeandcompositionEndTime` fields.
decode_itunes_date_field(data) -> datetime.datetime: The iTunes 'Date' meta field: a year or an ISO timestamp.deref_box(B, path): Dereference a path with respect to this Box.class DREFBoxBody(DREFBoxBody__original): A 'dref' Data Reference box containing Data Entry boxes - section 8.7.2.1.
DREFBoxBody.ENTRY_COUNT_TYPE
DREFBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
DREFBoxBody.__setattr__(self, attr, value):
Set a data field from value.
DREFBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
DREFBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
DREFBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
DREFBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
DREFBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
DREFBoxBody.transcribe(self):
Transcribe this instance.
class ELNGBoxBody(ELNGBoxBody__original): AELNGBoxBodyis a Extended Language Tag box - ISO14496 section 8.4.6.
ELNGBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
ELNGBoxBody.__setattr__(self, attr, value):
Set a data field from value.
ELNGBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
ELNGBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
ELNGBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
ELNGBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
ELNGBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
ELNGBoxBody.transcribe(self):
Transcribe this instance.
ELSTBoxBody.V0EditEntry
ELSTBoxBody.V1EditEntry
ELSTBoxBody.entry_class:
The class representing each entry.
ELSTBoxBody.entry_count:
The number of entries.
ELSTBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Parse the fields of an ELSTBoxBody.
ELSTBoxBody.transcribe(self):
Transcribe an ELSTBoxBody.
-
class EntryCountListOfBoxes(FullBoxBody2): An intermediateFullBoxBodysubclass which contains more boxes whose number if specified with a leadingentry_countwhose defaut type isUInt32BE.This is a common superclass of
_SampleTableContainerBoxBodyand
EntryCountListOfBoxes.entry_count:
The entry_count is the number of Boxes.
EntryCountListOfBoxes.parse_fields(bfr: cs.buffer.CornuCopyBuffer):
Gather the entry_count and boxes.
EntryCountListOfBoxes.transcribe(self):
Transcribe a EntryCountListOfBoxes.
class FREEBoxBody(BoxBody): A 'free' or 'skip' box - ISO14496 section 8.1.2. Note the length and discard the data portion.
FREEBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer, end_offset=Ellipsis, **kw):
Gather the padding field.
FREEBoxBody.transcribe(self):
Transcribe a FREEBoxBody.
class FTYPBoxBody(FTYPBoxBody__original): An 'ftyp' File Type box - ISO14496 section 4.3. Decode the major_brand, minor_version and compatible_brands.
FTYPBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
FTYPBoxBody.__setattr__(self, attr, value):
Set a data field from value.
FTYPBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
FTYPBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
FTYPBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
FTYPBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
FTYPBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
FTYPBoxBody.transcribe(self):
Transcribe this instance.
class FullBoxBody(BoxBody): A common extension of a basicBoxBody, with a version and flags field. ISO14496 section 4.2.
FullBoxBody.flags:
The flags value, computed from the 3 flag bytes.
FullBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the fields of FullBoxBody.
class FullBoxBody2(FullBoxBody2__original): A common extension of a basicBoxBody, with a version and flags field. ISO14496 section 4.2.
FullBoxBody2.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
FullBoxBody2.__setattr__(self, attr, value):
Set a data field from value.
FullBoxBody2.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
FullBoxBody2.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
FullBoxBody2.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
FullBoxBody2.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
FullBoxBody2.self_check(self):
An @binclass class instance's raw fields are in self._data.
FullBoxBody2.transcribe(self):
Transcribe this instance.
-
get_deref_path(path, offset=0): Parse apathstring fromoffset. Return the path components and the offset where the parse stopped.Path components:
- identifier: an identifier represents a
Boxfield or if such a field is not present, a the first subbox of this type [index]: the subbox with index index
Examples:
>>> get_deref_path('.abcd[5]') (['abcd', 5], 8) - identifier: an identifier represents a
-
class HDLRBoxBody(HDLRBoxBody__original): A HDLRBoxBody is a Handler Reference box - ISO14496 section 8.4.3.
HDLRBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
HDLRBoxBody.__setattr__(self, attr, value):
Set a data field from value.
HDLRBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
HDLRBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
HDLRBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
HDLRBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
HDLRBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
HDLRBoxBody.transcribe(self):
Transcribe this instance.
-
ILSTAofBSchema(attribute_name): Attribute name and type for ILST "A of B" schema. -
class ILSTBoxBody(ILSTBoxBody__original): Apple iTunes Information List, container for iTunes metadata fields.The basis of the format knowledge here comes from AtomicParsley's documentation here:
http://atomicparsley.sourceforge.net/mpeg-4files.htmland additional information from:
https://github.com/sergiomb2/libmp4v2/wiki/iTunesMetadata
ILSTBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
ILSTBoxBody.__setattr__(self, attr, value):
Set a data field from value.
ILSTBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
ILSTBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
ILSTBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
ILSTBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
ILSTBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
ILSTBoxBody.transcribe(self):
Transcribe this instance.
ILSTISOFormatSchema(attribute_name): Attribute name and type for ILST ISO format schema.ILSTRawSchema(attribute_name): Attribute name and type for ILST raw schema.ILSTTextSchema(attribute_name): Attribute name and type for ILST text schema.ILSTUInt32BESchema(attribute_name): Attribute name and type for ILSTUInt32BEschema.ILSTUInt8Schema(attribute_name): Attribute name and type for ILSTUInt8BEschema.class itunes_media_type(builtins.tuple): itunes_media_type(type, stik)
itunes_media_type.__replace__(self, /, **kwds):
Return a new itunes_media_type object replacing specified fields with new values
itunes_media_type.stik:
Alias for field number 1
itunes_media_type.type:
Alias for field number 0
class itunes_store_country_code(builtins.tuple): itunes_store_country_code(country_name, iso_3166_1_code, itunes_store_code)
itunes_store_country_code.__replace__(self, /, **kwds):
Return a new itunes_store_country_code object replacing specified fields with new values
itunes_store_country_code.country_name:
Alias for field number 0
itunes_store_country_code.iso_3166_1_code:
Alias for field number 1
itunes_store_country_code.itunes_store_code:
Alias for field number 2
ListOfBoxes.LIST_ITEM_TYPE
main(argv=None): Command line mode.class MDATBoxBody(BoxBody): A Media Data Box - ISO14496 section 8.1.1.
MDATBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather all data to the end of the field.
MDATBoxBody.transcribe(self):
Transcribe the data.
Raise an AssertionError if we skipped the data during the parse.
MDATBoxBody.transcribed_length(self):
Return the transcription length even if we didn't keep the data.
MDHDBoxBody.language:
The ISO 639‐2/T language code as decoded from the packed form.
MDHDBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the creation_time, modification_time, timescale,
duration and language_short fields.
MDHDBoxBody.transcribe(self):
Transcribe a MDHDBoxBody.
METABoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
METABoxBody.__setattr__(self, attr, value):
Set a data field from value.
METABoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
METABoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
METABoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
METABoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
METABoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
METABoxBody.transcribe(self):
Transcribe this instance.
class MOOVBoxBody(MOOVBoxBody__original): An 'moov' Movie box - ISO14496 section 8.2.1. Decode the contained boxes.
MOOVBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
MOOVBoxBody.__setattr__(self, attr, value):
Set a data field from value.
MOOVBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
MOOVBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
MOOVBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
MOOVBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
MOOVBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
MOOVBoxBody.transcribe(self):
Transcribe this instance.
MVHDBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
MVHDBoxBody.__setattr__(self, attr, value):
Set a data field from value.
MVHDBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
MVHDBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
MVHDBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
MVHDBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
MVHDBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
MVHDBoxBody.transcribe(self):
Transcribe this instance.
-
parse_tags(path, tag_prefix=None): Parse the tags frompath. Yield(box,tags)for each subbox with tags.The optional
tag_prefixparameter may be specified to prefix each tag name with a prefix. Other keyword arguments are passed toparse()(typical example:discard_data=True). -
class PDINBoxBody(FullBoxBody2): A 'pdin' Progressive Download Information box - ISO14496 section 8.1.3.
PDINBoxBody.PDInfo
SMHDBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
SMHDBoxBody.__setattr__(self, attr, value):
Set a data field from value.
SMHDBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
SMHDBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
SMHDBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
SMHDBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
SMHDBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
SMHDBoxBody.transcribe(self):
Transcribe this instance.
STCOBoxBody.chunk_offsets:
Parse the UInt32BE chunk offsets from stashed buffer.
STCOBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the entry_count and chunk_offsets fields.
STCOBoxBody.transcribe(self):
Transcribe a STCOBoxBody.
class STDPBoxBody(STDPBoxBody__original): ASTDPBoxBodyis a DegradationPriorityBox - ISO14496 section 8.5.3.2.
STDPBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
STDPBoxBody.__setattr__(self, attr, value):
Set a data field from value.
STDPBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
STDPBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
STDPBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
STDPBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
STDPBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
STDPBoxBody.transcribe(self):
Transcribe this instance.
STSCBoxBody.STSCEntry
STSCBoxBody.entries:
A list of ints parsed from the STSCEntry list.
STSCBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the entry_count and entries fields.
STSCBoxBody.transcribe(self):
Transcribe a STSCBoxBody.
class STSDBoxBody(STSDBoxBody__original): ASTSDBoxBodyis a SampleDescriptionBoxBody - ISO14496 section 8.5.2.2.
STSDBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
STSDBoxBody.__setattr__(self, attr, value):
Set a data field from value.
STSDBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
STSDBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
STSDBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
STSDBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
STSDBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
STSDBoxBody.transcribe(self):
Transcribe this instance.
STSZBoxBody.entry_sizes:
Parse the UInt32BE entry sizes from stashed buffer
into a list of ints.
STSZBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the sample_size, sample_count, and entry_sizes fields.
STSZBoxBody.transcribe(self):
Transcribe the STSZBoxBody.
STZ2BoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the field_size, sample_count and entry_sizes fields.
STZ2BoxBody.transcribe(self):
Transcribe the STZ2BoxBody.
class TimeStamp32(cs.binary.UInt32BE, TimeStampMixin): The 32 bit form of an ISO14496 timestamp.class TimeStamp64(cs.binary.UInt64BE, TimeStampMixin): The 64 bit form of an ISO14496 timestamp.class TimeStampMixin: Methods to assist with ISO14496 timestamps.
TimeStampMixin.datetime:
This timestamp as an UTC datetime.
TimeStampMixin.unixtime:
This timestamp as a UNIX time (seconds since 1 January 1970).
TKHDBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
TKHDBoxBody.__setattr__(self, attr, value):
Set a data field from value.
TKHDBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
TKHDBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
TKHDBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
TKHDBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
TKHDBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
TKHDBoxBody.transcribe(self):
Transcribe this instance.
class TrackGroupTypeBoxBody(FullBoxBody): A TrackGroupTypeBoxBody contains a track group id - ISO14496 section 8.3.3.2.
TrackGroupTypeBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the track_group_id field.
class TrackReferenceTypeBoxBody(BoxBody): A TrackReferenceTypeBoxBody contains references to other tracks - ISO14496 section 8.3.3.2.
TrackReferenceTypeBoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the track_ids field.
class TREFBoxBody(ContainerBoxBody): Track Reference BoxBody, container for trackReferenceTypeBoxes - ISO14496 section 8.3.3.class TTSB_Sample(builtins.tuple): TTSB_Sample(count, delta)
TTSB_Sample.__replace__(self, /, **kwds):
Return a new TTSB_Sample object replacing specified fields with new values
TTSB_Sample.count:
Alias for field number 0
TTSB_Sample.delta:
Alias for field number 1
URL_BoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the location field.
URN_BoxBody.parse_fields(self, bfr: cs.buffer.CornuCopyBuffer):
Gather the name and location fields.
URN_BoxBody.transcribe(self):
Transcribe a URN_BoxBody.
UTF8or16Field.parse(bfr: cs.buffer.CornuCopyBuffer):
Gather optional BOM and then UTF8 or UTF16 string.
UTF8or16Field.transcribe(self):
Transcribe the field suitably encoded.
VMHDBoxBody.__getattr__(self, attr: str):
Return a data field value, the .value attribute if it is a single value field.
VMHDBoxBody.__setattr__(self, attr, value):
Set a data field from value.
VMHDBoxBody.parse(bfr: cs.buffer.CornuCopyBuffer):
Parse an instance from bfr.
This default implementation calls cls(**cls.parse_fields(bfr)).
VMHDBoxBody.parse_field(fieldname: str, bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Optional[Mapping[str, type]] = None):
Parse an instance of the field named fieldname from bfr.
Return the field instance.
VMHDBoxBody.parse_fields(bfr: cs.buffer.CornuCopyBuffer, fieldtypes: Union[Mapping[str, type], Iterable[str], str, NoneType] = None) -> Mapping[str, cs.binary.AbstractBinary]:
Parse all the fields from cls._datafieldtypes from bfr
by calling cls.parse_field(fieldname,bfr) for each.
Return a mapping of field names to values
suitable for passing to cls.
The fieldtypes defaults to cls._datafieldtypes but may be provided as:
- a mapping of field name to type
- an iterable of field names, whose types will come from
cls._datafieldtypes - a string being a space separated list of field names,
whose types will come from
cls._datafieldtypes
Each of these will be converted to a mapping and then
promoted with promote_fieldtypemap.
VMHDBoxBody.promote_field_value(fieldname: str, obj):
Promote a received obj to the appropriate AbstractBinary instance.
VMHDBoxBody.self_check(self):
An @binclass class instance's raw fields are in self._data.
VMHDBoxBody.transcribe(self):
Transcribe this instance.
Release Log
Release 20260531:
- BoxBody: provide a default boxes=() class attribute; drop HasBoxesMixin, already covered by BoxBody.getattr.
- Box.ancestor: raise ValueError if no matching ancestor is found.
- Box.BOX_TYPE: raise AttributeError if we cannot derive the type from the class name.
- Box.walk: yield (level,box,subboxes) 3-tuples to allow the called to track depth.
- MP4Command: rename cmd_parse to cmd_scan.
- BoxBody.iter: iterate self.boxes, not (), now that we always have a self.boxes.
- Box,BoxHeader: support for boxes with a UUID as the type.
- drop dump_box() in favour of new Box.dump_table and box.dump methods, add a recursion limit to Box.walk.
- Box: new .descendants() method to scan a Box hierarchy for boxes of specified types.
- MP4Command.cmd_scan: accept just one filename, following arguments are box types of interest.
- BoxBody.parse_field: accept ... in addition to an int to parse raw bytes.
- Drop OverBox.
- @boxbodyclass: decorator wrapping @binclass which reregisters the new class as the body handler for its box type.
- New FulBoxBody2 @binclass based class, hopefully will replace FullBoxBody in the fullness of time.
- Drop parse_fields(), obsoleted by Box.scan().
- Refactor the ILST box schemas as namedtuples.
- New ListOfBoxes(ListOfBinary,item_type=Box) class.
- Reimplement several box classes using @binclass.
- Box.box_type_s: ensure an ASCII box type is entirely printable (no control characters).
- ILSTBoxBody: make a SUBBOX_SCHEMA_BY_LONG_ATTRIBUTE to avoid a linear search in getattr.
- Box.parse: new body_type_for=None parameter for providing a custom box_type->BoxBody-class function, intended for the ILST subboxes.
- Drop the top level parse() function.
- Box: new .report_table() and .report() analogues for .dump_table() and .dump() but with human friendly summary information.
- Drop top level report() function, supplanted by Box.report_table() and Box.report().
- Box: new len returning the parsed length from .offset and .end_offset; new bool returning True to avoid implied call of len() for truthiness.
- Assorted other changes.
Release 20241122: Replace many raises of RuntimeError with NotImplementedError, suggestion by @dimaqq on disucss.python.org.
Release 20240422:
- Replace dropped UTF16NULField with BinaryUTF16NUL.
- Comment out unused CO64BoxBody.chunk_offsets, uses dropped (and not replaced) deferred_field.
- Drop FallbackBoxBody, we'll just use BoxBody when there's no box specific subclass.
- Replace pick_boxbody_class with BoxBody.for_box_type.
- Rename boxbody_type_from_klass to boxbody_type_from_class.
- Drop obsolete KNOWN_BOXBODY_CLASSES.
- MP4Command.cmd_info: print moov.udta.meta.ilst.cover in SIXEL format on a terminal.
- Rename parse_deref_path to get_deref_path like other lexical functions.
- ILSTBoxBody.getattr: fix lookup of long names.
Release 20231129: Small updates and fixes.
Release 20230212:
- Drop cs.context.StackableState in favour of cs.threads.State.
- MP4Command.cmd_autotag: use @uses_fstags for the fstags parameter.
Release 20220606: Update obsolete use of Tag.with_prefix.
Release 20210306:
- Huge refactor of the Box classes to the new Binary* classes from cs.binary.
- mp4: new "tags" subcommand to print the tags parsed from a file.
- BoxHeader: fix the definition of MAX_BOX_SIZE_32.
- BoxBody: new parse_boxes utility method to part the remainder of a Box as subBoxes.
- MP4.cmd_parse: run the main parse in discard_data=True mode.
- METABoxBody.getattr: fix ILST typo.
- MP4Command: update for new cs.cmdutils.BaseCommand API.
- Many small fixes and tweaks.
Release 20200229:
- ILST: recognise @cpy as copyright, sfID as itunes_store_country_code.
- ILST: new SFID_ISO_3166_1_ALPHA_3_CODE and STIK_MEDIA_TYPES providing context data for various field values, as yet unused.
- Make various list fields of some boxes deferred because they are expensive to parse (uses new cs.binary deferred_field).
- add_generic_sample_boxbody: drop iter, causes dumb iterators to parse the samples.
- ILST: iTunes "Date" metadata seem to contain plain years or ISO8601 datestamps.
- mp4 autotag: add -n (no action) and -p,--prefix (set tag prefix, default 'mp4') options.
- mp4 autotag: use "mp4." as the tag prefix.
Release 20200130:
- Parsing of ILST boxes (iTunes metadata).
- Command line: new "info" subcommand reporting metadata, "autotag" applying metadata to fstags.
- Box tree walk, ancestor, iteration.
- Assorted cleanups and internal changes.
Release 20190220: parse_buffer yields instead of returns; some small bugfixes.
Release 20180810:
- parse_fd(): use a mmap to access the descriptor if a regular file and not discard_data;
- this lets us use the mmapped file as backing store for the data, a big win for the media sections.
Release 20180805: Initial PyPI release.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file cs_iso14496-20260531.tar.gz.
File metadata
- Download URL: cs_iso14496-20260531.tar.gz
- Upload date:
- Size: 46.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f1c5c3f0c829bcaf9d4290c307a8c5f5df9ceb5367ff6c289eebad28b81464bf
|
|
| MD5 |
7c5cd594b22e4f65fdb67b1503358192
|
|
| BLAKE2b-256 |
eacf467207d094525d68ced4c9d441b5dcc74cfecf0a5f8f5873977c6c76ecb3
|
File details
Details for the file cs_iso14496-20260531-py2.py3-none-any.whl.
File metadata
- Download URL: cs_iso14496-20260531-py2.py3-none-any.whl
- Upload date:
- Size: 36.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d0bebc56bd5a394e3f3ca77e0cf54398745eebc4d433e2155787ae6b82403f41
|
|
| MD5 |
8cc4d5712bceff934fd1e9e6103147d0
|
|
| BLAKE2b-256 |
1191ca84422727520cea15b4de7cfcbd689521d1edb9c869c4dd7193b68671e4
|