View Source ExMP4.Track (MP4 Reader and Writer v0.6.0)

A struct describing an MP4 track.

Summary

Types

t()

Struct describing an mp4 track.

Functions

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

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

Create a new track

Types

@type id() :: non_neg_integer()
@type t() :: %ExMP4.Track{
  _chunk_id: term(),
  _iter_duration: term(),
  _iter_index: term(),
  _stsc_entry: term(),
  channels: non_neg_integer() | nil,
  duration: non_neg_integer(),
  height: non_neg_integer() | nil,
  id: id(),
  media: :h264 | :h265 | :aac | :opus | :unknown,
  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: :video | :audio | :subtitle | :unknown,
  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

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

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

Link to this function

duration(track, unit_or_timescale \\ :millisecond)

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

Get the duration of the track.

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

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

@spec from_trak(ExMP4.Box.Trak.t()) :: t()
@spec new(Keyword.t()) :: t()

Create a new track

Link to this function

to_trak(track, movie_timescale)

View Source
@spec to_trak(t(), ExMP4.timescale()) :: ExMP4.Box.Trak.t()