This plugin provides utilities for MP4 container parsing and serialization along with elements for muxing the stream to MP4 or CMAF.
The package can be installed by adding membrane_mp4_plugin
to your list of dependencies in mix.exs
:
defp deps do
[
{:membrane_mp4_plugin, "~> 0.35.2"}
]
end
ISOM muxer requires a sink that can handle Membrane.File.SeekSinkEvent
, e.g. Membrane.File.Sink
.
For an example of muxing streams to a regular MP4 file, refer to examples/muxer_isom.exs
.
To run the example, you can use the following command:
elixir examples/muxer_isom.exs
You can expect an example.mp4
file containing muxed audio and video to be saved in your working directory.
For an example of muxing streams into CMAF format, refer to examples/muxer_cmaf.exs
. CMAF requires a special sink, regular Membrane.File.Sink
will not work correctly. Currently, Membrane Framework has only one sink capable of saving a CMAF stream - Membrane.HTTPAdaptiveStream.Sink
.
To run the example, use the following command:
elixir examples/muxer_cmaf.exs
You can expect hls_output
folder to appear and be filled with CMAF header and segments, as well as an HLS playlist.
To play the stream, you need to serve the contents of the output folder with an HTTP Server. If you are looking for
something quick and simple, you can use Python's http.server
:
python3 -m http.server -d hls_output 8000
and run the following command to play the stream:
ffplay http://localhost:8000/index.m3u8
In case out_*
reference files in test/fixtures/cmaf
change, out_playlist.m3u8
and its dependent playlists should be updated and checked if they are still playable.
The current files have been checked with ffplay (FFmpeg) and Safari.
Copyright 2019, Software Mansion
Licensed under the Apache License, Version 2.0