ExMP4.Track (MP4 Reader and Writer v0.14.1)

View Source

A struct describing an MP4 track.

Summary

Types

t()

Struct describing an mp4 track.

Functions

Gets the bitrate of the track in bps (bit per second)

Gets the duration of the track.

Gets the fps (frames per second) of the video track.

Creates a new track

Gets the next sample.

Types

codecs()

@type codecs() :: :av1 | :h264 | :h265 | :vp8 | :vp9 | :aac | :opus | :raw | :unknown

id()

@type id() :: non_neg_integer()

media_types()

@type media_types() :: :video | :audio | :subtitle | :unknown

t()

@type t() :: %ExMP4.Track{
  _chunk_id: term(),
  _iter_duration: term(),
  _reducer: term(),
  _stsc_entry: term(),
  channels: non_neg_integer() | nil,
  duration: non_neg_integer(),
  height: non_neg_integer() | nil,
  id: id(),
  media: codecs(),
  media_tag: atom(),
  movie_duration: term(),
  priv_data: binary() | struct(),
  sample_count: non_neg_integer(),
  sample_rate: non_neg_integer() | nil,
  sample_table: ExMP4.Box.Stbl.t() | nil,
  timescale: non_neg_integer(),
  trafs: [ExMP4.Box.Traf.t()],
  trex: ExMP4.Box.Trex.t() | nil,
  type: media_types(),
  width: non_neg_integer() | nil
}

Struct describing an mp4 track.

The public fields are:

  • :id - the track id

  • :type - the type of the media of the track

  • :media - the codec used to encode the media.

  • :media_tag - the box name to use for the :media.

    This field is used to indicate the layout of some codec specific data, take for example H264, avc1 indicates that parameter sets are included in the sample description and removed from the samples themselves.

  • :priv_data - private data specific to the contained :media.

  • :duration - the duration of the track in :timescale units.

  • :timescale - the timescale used for the track.

  • :width - the width of the video frames.

  • :height - the height of the video frames.

  • :sample_rate - the sample rate of audio samples.

  • :channels - the number of audio channels.

  • :sample_count - the total count of samples.

Functions

bitrate(track)

@spec bitrate(t()) :: non_neg_integer()

Gets the bitrate of the track in bps (bit per second)

duration(track, unit_or_timescale \\ :millisecond)

@spec duration(t(), ExMP4.Helper.timescale()) :: integer()

Gets the duration of the track.

fps(track)

@spec fps(t()) :: number()

Gets the fps (frames per second) of the video track.

new(opts)

@spec new(Keyword.t()) :: t()

Creates a new track

next_sample(track)

@spec next_sample(t()) :: {ExMP4.SampleMetadata.t(), t()} | :done

Gets the next sample.