View Source Membrane.MP4.Container (Membrane MP4 plugin v0.16.2)

Module for parsing and serializing MP4 files.

Bases on MP4 structure specification from Membrane.MP4.Container.Schema.

Link to this section Summary

Functions

Maps a path in the MP4 box tree into sequence of keys under which that box resides in MP4.

Gets a box from a given path in a parsed MP4.

Same as parse/1, raises on error.

Same as parse/2, raises on error.

Parses binary data to MP4 according to Membrane.MP4.Container.Schema.schema/0.

Parses binary data to MP4 according to a custom schema.

Same as serialize/1, raises on error

Same as serialize/2, raises on error

Serializes MP4 to a binary according to Membrane.MP4.Container.Schema.schema/0.

Serializes MP4 to a binary according to a custom schema.

Updates a box at a given path in a parsed MP4.

Link to this section Types

@type box_name_t() :: atom()
@type field_name_t() :: atom()
@type fields_t() :: %{required(field_name_t()) => term() | [term()] | fields_t()}
Link to this type

parse_error_context_t()

View Source
@type parse_error_context_t() :: [
  box: box_name_t(),
  field: field_name_t(),
  data: bitstring(),
  reason:
    :box_header | {:box_size, header: pos_integer(), actual: pos_integer()}
]
Link to this type

serialize_error_context_t()

View Source
@type serialize_error_context_t() :: [box: box_name_t(), field: field_name_t()]
@type t() :: [
  {box_name_t(), %{content: binary()} | %{fields: fields_t(), children: t()}}
]

Link to this section Functions

@spec box_path(box_name_t() | [box_name_t()]) :: [atom()]

Maps a path in the MP4 box tree into sequence of keys under which that box resides in MP4.

@spec get_box(t(), box_name_t() | [box_name_t()]) :: t()

Gets a box from a given path in a parsed MP4.

@spec parse!(binary()) :: t()

Same as parse/1, raises on error.

@spec parse!(binary(), Membrane.MP4.Container.Schema.t()) :: t()

Same as parse/2, raises on error.

@spec parse(binary()) :: {:ok, t()} | {:error, parse_error_context_t()}

Parses binary data to MP4 according to Membrane.MP4.Container.Schema.schema/0.

@spec parse(binary(), Membrane.MP4.Container.Schema.t()) ::
  {:ok, t()} | {:error, parse_error_context_t()}

Parses binary data to MP4 according to a custom schema.

@spec serialize!(t()) :: binary()

Same as serialize/1, raises on error

@spec serialize!(t(), Membrane.MP4.Container.Schema.t()) :: binary()

Same as serialize/2, raises on error

@spec serialize(t()) :: {:ok, binary()} | {:error, serialize_error_context_t()}

Serializes MP4 to a binary according to Membrane.MP4.Container.Schema.schema/0.

@spec serialize(t(), Membrane.MP4.Container.Schema.t()) ::
  {:ok, binary()} | {:error, serialize_error_context_t()}

Serializes MP4 to a binary according to a custom schema.

Link to this function

update_box(mp4, path, parameter_path \\ [], f)

View Source
@spec update_box(t(), box_name_t() | [box_name_t()], [atom()], (term() -> term())) ::
  t()

Updates a box at a given path in a parsed MP4.

If parameter_path is set, a parameter within a box is updated.