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

Module for parsing and serializing MP4 files.

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

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.

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 parse/1, raises on error.

Same as parse/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.

Same as serialize/1, raises on error

Same as serialize/2, raises on error

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

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()}}
]

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()) ::
  {:ok, t(), leftover :: binary()} | {:error, parse_error_context_t()}

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

Returns boxes that have been correctly parsed, and the leftover data that is insufficient to constitute a complete box.

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

Parses binary data to MP4 according to a custom schema.

Returns boxes that have been correctly parsed, and the leftover data that is insufficient to constitute a complete box.

@spec parse!(binary()) :: {t(), leftover :: binary()}

Same as parse/1, raises on error.

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

Same as parse/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.

@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

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.