View Source ExMP4.Writer (MP4 Reader and Writer v0.2.0)

This module contains functions to write MP4.

Summary

Functions

Add a new track.

Add multiple tracks.

Create a new mp4 writer that writes to filesystem.

The same as new/2, but raises if it fails.

Write the mp4 header.

Write the trailer and close the stream.

Types

@type new_opts() :: [{:fast_start, boolean()}]
@type t() :: %ExMP4.Writer{
  fast_start: boolean(),
  ftyp_size: integer(),
  mdat_size: integer(),
  next_track_id: term(),
  tracks: %{required(non_neg_integer()) => ExMP4.Track.t()},
  writer_mod: module(),
  writer_state: any()
}

Functions

Link to this function

add_track(writer, track)

View Source
@spec add_track(t(), ExMP4.Track.t()) :: t()

Add a new track.

A track is created by instantiating the public fields of ExMP4.Track. The id is assigned by the writer and it's equals to the index of the track starting from 1. The first track has an id 1, the second 2, ...etc.

Link to this function

add_tracks(writer, tracks)

View Source
@spec add_tracks(t(), [ExMP4.Track.t()]) :: t()

Add multiple tracks.

Link to this function

new(filepath, opts \\ [])

View Source
@spec new(Path.t(), new_opts()) :: {:ok, t()} | {:error, reason :: any()}

Create a new mp4 writer that writes to filesystem.

The following options can be provided:

  • fast_start - Move the moov box to the beginning of the file. Defaults to: false
Link to this function

new!(filepath, opts \\ [])

View Source
@spec new!(Path.t(), new_opts()) :: t()

The same as new/2, but raises if it fails.

Link to this function

write_header(writer, opts \\ [])

View Source
@spec write_header(t(), Keyword.t()) :: t()

Write the mp4 header.

This function should be called first before adding tracks.

Link to this function

write_sample(writer, sample)

View Source
@spec write_sample(t(), ExMP4.Sample.t()) :: t()

Write a sample.

@spec write_trailer(t()) :: :ok

Write the trailer and close the stream.