/membrane_camera_capture_plugin

A set of elements allowing for capturing local media such as camera or microphone

Primary LanguageElixirApache License 2.0Apache-2.0

Membrane Camera Capture Plugin

Hex.pm API Docs CircleCI

This plugin can be used to capture video stream from an input device.

It is part of Membrane Multimedia Framework.

Installation

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

def deps do
  [
    {:membrane_camera_capture_plugin, "~> 0.4.0"}
  ]
end

Sample Usage

Dependencies:

def deps do
  [
    {:membrane_camera_capture_plugin, "~> 0.4.0"},
    {:membrane_h264_ffmpeg_plugin, "~> 0.21"},
    {:membrane_file_plugin, "~> 0.10"},
    {:membrane_ffmpeg_swscale_plugin, "~> 0.10"}
  ]
end
defmodule Example do
  use Membrane.Pipeline

  @impl true
  def handle_init(_ctx, _options) do
    structure = 
      child(:source, Membrane.CameraCapture) 
      |> child(:converter, %Membrane.FFmpeg.SWScale.PixelFormatConverter{format: :I420}) 
      |> child(:encoder, Membrane.H264.FFmpeg.Encoder) 
      |> child(:sink, %Membrane.File.Sink{location: "output.h264"}) 

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

Testing

Running this manual test, you should be able to record a 5-sec long video stream from your webcam and then play it using ffplay (you need to have ffmpeg installed).

To run manual tests, you need to install dependencies:

$ mix deps.get

And run manual (you observe the result and decide whether it works) tests:

$ mix test --include manual

If run successfully, you should be able to see video recorded by your camera.

Copyright and License

Copyright 2022, Software Mansion

Software Mansion

Licensed under the Apache License, Version 2.0