View Source Membrane FFmpeg Video Filter Plugin

Hex.pm API Docs CircleCI

This package contains elements providing video filters based on ffmpeg video filter feature.

Currently only the TextOverlay element is implemented, based on ffmpeg drawtext filter. This element enables adding text on top of given raw video frames.

PRs with the implementation of other video filters are welcome!

installation

Installation

The package can be installed by adding membrane_ffmpeg_video_filter_plugin to your list of dependencies in mix.exs:

def deps do
  [
	  {:membrane_ffmpeg_video_filter_plugin, "~> 0.9.0"}
  ]
end

usage

Usage

textoverlay

TextOverlay

Below example pipeline adds "John Doe" text over h264 video in a specified style.

defmodule VideoFilter.Pipeline do
  use Membrane.Pipeline

  alias Membrane.File.{Sink, Source}
  alias Membrane.H264.FFmpeg.{Parser, Decoder, Encoder}
  alias Membrane.FFmpeg.VideoFilter.TextOverlay

  @impl true
  def handle_init(_ctx, _opts) do
    structure = 
      child(:file_src, %Source{location: "input.h264"}) 
      |> child(:parser, %Parser{framerate: {10, 1}}) 
      |> child(:decoder, Decoder) 
      |> child(:text_filter, %TextOverlay{
          text: "John Doe",
          x: :center,
          fontsize: 25,
          fontcolor: "white",
          border?: true
        }
      ) 
      |> child(:encoder,  Encoder) 
      |> child(:file_sink,  %Sink{location: "output.h264"})
  
    {[spec: structure], %{}}
  end
end

Frame from original video:

input

Output frame with filter applied:

output

Copyright 2021, Software Mansion

Software Mansion

Licensed under the Apache License, Version 2.0