Packages
membrane_h264_ffmpeg_plugin
0.31.3
0.32.7
0.32.6
0.32.5
0.32.4
0.32.3
0.32.2
0.32.1
0.32.0
0.31.8
0.31.7
0.31.6
0.31.5
0.31.4
0.31.3
0.31.2
0.31.1
0.31.0
0.30.1
0.30.0
0.29.0
0.28.2
0.28.1
0.28.0
0.27.0
0.26.2
0.26.1
0.26.0
0.25.4
0.25.3
0.25.2
0.25.1
0.25.0
0.24.0
0.23.0
0.22.1
0.22.0
0.21.6
0.21.5
0.21.4
0.21.3
0.21.2
0.21.1
0.21.0
0.20.1
0.20.0
0.19.0
0.18.0
0.17.0
0.16.3
0.16.2
0.16.1
0.16.0
0.15.0
0.14.0
0.13.3
0.13.2
0.13.1
0.13.0
0.12.2
0.12.1
0.12.0
0.11.0
0.10.0
0.9.0
0.8.0
0.7.0
0.6.0
0.5.0
Membrane H264 decoder and encoder based on FFmpeg and x264
Current section
Files
Jump to
Current section
Files
membrane_h264_ffmpeg_plugin
README.md
README.md
# Membrane H264 FFmpeg plugin
[](https://hex.pm/packages/membrane_h264_ffmpeg_plugin)
[](https://hexdocs.pm/membrane_h264_ffmpeg_plugin/)
[](https://circleci.com/gh/membraneframework/membrane_h264_ffmpeg_plugin)
This package provides H264 video decoder and encoder, based on [ffmpeg](https://www.ffmpeg.org)
and [x264](https://www.videolan.org/developers/x264.html).
It is a part of the [Membrane Multimedia Framework](https://membraneframework.org)
Documentation is available at [HexDocs](https://hexdocs.pm/membrane_h264_ffmpeg_plugin/)
Note: `Membrane.H264.FFmpeg.Parser` has been removed. Now you can use our pure Elixir implementation of the H264 parser: [`Membrane.H264.Parser`](https://hexdocs.pm/membrane_h264_plugin/Membrane.H264.Parser.html) from [membrane_h264_plugin](https://github.com/membraneframework/membrane_h264_plugin).
## Installation
Add the following line to your `deps` in `mix.exs`. Run `mix deps.get`.
```elixir
{:membrane_h264_ffmpeg_plugin, "~> 0.31.3"}
```
This package depends on the [ffmpeg](https://www.ffmpeg.org) libraries. The precompiled builds will be pulled and linked automatically. However, should there be any problems, consider installing it manually.
### Manual instalation of dependencies
#### Ubuntu
```bash
sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev
```
#### Arch/Manjaro
```bash
pacman -S ffmpeg
```
#### MacOS
```bash
brew install ffmpeg
```
## Usage Example
### Decoder
The following pipeline takes 30fps H264 file and decodes it to the raw video.
```elixir
Logger.configure(level: :info)
Mix.install([
:membrane_h264_ffmpeg_plugin,
:membrane_h264_plugin,
:membrane_file_plugin,
:req
])
h264 = Req.get!("https://raw.githubusercontent.com/membraneframework/static/gh-pages/samples/ffmpeg-testsrc.h264").body
File.write!("input.h264", h264)
defmodule Decoding.Pipeline do
use Membrane.Pipeline
@impl true
def handle_init(_ctx, _opts) do
structure =
child(%Membrane.File.Source{chunk_size: 40_960, location: "input.h264"})
|> child(Membrane.H264.Parser)
|> child(Membrane.H264.FFmpeg.Decoder)
|> child(%Membrane.File.Sink{location: "output.raw"})
{[spec: structure], %{}}
end
end
Membrane.Pipeline.start_link(Decoding.Pipeline)
```
### Encoder
The following pipeline takes 720p raw video file as input and encodes it as H264.
```elixir
defmodule Encoding.Pipeline do
use Membrane.Pipeline
@impl true
def handle_init(_) do
structure =
child(:source, %Membrane.File.Source{chunk_size: 40_960, location: "input.raw"})
|> child(:parser, %Membrane.RawVideo.Parser{width: 1280, height: 720, pixel_format: :I420})
|> child(:encoder, %Membrane.H264.FFmpeg.Encoder{preset: :fast, crf: 30})
|> child(:sink, %Membrane.File.Sink{location: "output.h264"})
{[spec: structure], %{}}
end
end
```
## Copyright and License
Copyright 2018, [Software Mansion](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=membrane)
[](https://swmansion.com/?utm_source=git&utm_medium=readme&utm_campaign=membrane)