API Reference ISOMedia v#0.1.0

Copy Markdown View Source

Modules

Lossless ISOBMFF (MP4/MOV/M4A/HEIF) box surgery in pure Elixir.

A single generic ISOBMFF box.

Navigate and update a single box by a child-type path. Shared by Extract, Trim, and Concat (which all walk trak/mdia/minf/stbl subtrees).

Typed view of the stco (32-bit) and co64 (64-bit) Chunk Offset Boxes. kind is :stco or :co64; offsets is a list of absolute file offsets.

Typed view of the elst Edit List Box (inside trakedts).

Typed view of the ftyp File Type Box.

Typed view of the hdlr Handler Reference Box.

Typed view of the mdhd Media Header Box. Exposes timescale/duration (and creation/modification times); the trailing language + pre_defined fields are preserved in rest.

Typed view of the mvhd Movie Header Box. Exposes timescale/duration (and creation/modification times); all trailing fields (rate, volume, matrix, next_track_ID, ...) are preserved verbatim in rest.

Typed view of the trex Track Extends box (inside moovmvex).

Typed view of the tfdt Track Fragment Decode Time box.

Typed view of the tfhd Track Fragment Header box.

Typed view of the tkhd Track Header Box. Exposes track_id/duration (and creation/modification times); trailing fields are preserved in rest.

Typed view of the trun Track Run box (per-sample list).

Losslessly concatenate N compatible clips end-to-end.

Repack a fragmented MP4 (moof/traf/trun) into a standard progressive [ftyp, moov, mdat] — a pure metadata edit, no transcoding. Samples come from FragmentIndex; the output is assembled by ISOMedia.ProgressiveBuild, so the mdat is a recursive segment list referencing each fragment's bytes (memory-safe).

Track discovery and single-track extraction.

An inert reference to a byte range on disk: %FileSlice{path, offset, length}.

Repack a progressive MP4 into a single multiplexed fragmented tree [ftyp, moov(+mvex), moof, mdat, …]. Keyframe-aligned (a fragment starts on a sync sample so it is independently decodable), lossless (sample bytes via a Phase 8 segment-list mdat), memory-safe. The inverse of ISOMedia.Defragment.

Indexes fragmented MP4 (moof/traf/trun) into the same [%ISOMedia.Sample{}] the progressive indexer produces. Offsets are resolved tree-locally (a single Layout walk stamps each moof's position), and the cascade trun → tfhd → trex resolves per-sample duration/size/flags. chunk_index is a per-trun counter.

Helper for the version (1 byte) + flags (3 bytes) prefix that many ISOBMFF boxes (FullBoxes) carry before their payload.

Computes absolute byte offsets for a box tree in its current arrangement, matching exactly how ISOMedia.Serializer lays bytes out. Used to find where boxes land after editing so chunk offsets can be recomputed.

Parses an ISOBMFF file without loading it entirely into memory.

Resolves an absolute file byte range to a payload segment, given the top-level mdat boxes of a parsed tree. Returns a %FileSlice{} when the containing mdat is lazy, or a binary slice when it is in memory. Shared by Extract and Trim.

Recomputes stco/co64 chunk-offset tables after boxes have moved, and the faststart/1 rearrangement built on top of it.

Decodes an ISOBMFF binary into a list of ISOMedia.Box structs.

Assemble a progressive [ftyp, moov, mdat] tree from one or more inputs' per-track samples + mdat sources. Shared by Concat (N inputs) and Defragment (one input). Preserves interleave (runs sorted by original offset for the byte layout) while keeping logical {input, chunk} order for each track's stco.

Classifies which box types are containers (hold child boxes).

One media sample, decoded from a track's sample tables.

Decodes a track's stbl sample tables into an ordered list of ISOMedia.Sample.

Split a fragmented MP4 tree (the output of ISOMedia.fragment/2, shape [ftyp, moov, (moof, mdat)+]) into the DASH/CMAF on-disk layout: a media-less init segment ([ftyp, moov]) plus N standalone media segments ([styp, moof, mdat]).

Serializes ISOMedia.Box trees back into ISOBMFF binary.

Integer timescale rescaling shared across editing operations.

Losslessly trim every track to a time range [start_sec, end_sec).