Skip to content

gBillal/membrane_h265_ffmpeg_plugin

Repository files navigation

Membrane H265 FFmpeg plugin

Hex.pm API Docs

This package provides H265 video decoder and encoder, based on ffmpeg.

Documentation is available at HexDocs

Installation

Add the following line to your deps in mix.exs. Run mix deps.get.

{:membrane_h265_ffmpeg_plugin, "~> 0.4.1"}

This package depends on the ffmpeg 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

sudo apt-get install libavcodec-dev libavformat-dev libavutil-dev

Arch/Manjaro

pacman -S ffmpeg

MacOS

brew install ffmpeg

Usage Example

Decoder

The following pipeline takes 30fps H265 file and decodes it to the raw video.

defmodule Decoding.Pipeline do
  use Membrane.Pipeline

  alias Membrane.H265

  @impl true
  def handle_init(_ctx, _opts) do
    structure =
      child(:source, %Membrane.File.Source{chunk_size: 40_960, location: "input.h265"})
      |> child(:parser, H265.Parser)
      |> child(:decoder, H265.FFmpeg.Decoder)
      |> child(:sink,  %Membrane.File.Sink{location: "output.raw"})

    {[spec: structure], %{}}
  end
end

Encoder

The following pipeline takes 720p raw video file as input and encodes it as H265.

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.H265.FFmpeg.Encoder{preset: :fast, crf: 30})
      |> child(:sink, %Membrane.File.Sink{location: "output.h265"})

    {[spec: structure], %{}}
  end
end

About

Membrane H265 decoder and encoder based on FFmpeg and x265

Resources

License

Stars

Watchers

Forks

Packages

No packages published