itsok

itsok

Can't play videos recorded with `membrane_camera_capture_plugin`

I’m trying to use Membrane.CameraCapture to record a video from my computer camera.

When I clone the package repo and run the tests mix test --include manual, I can play the video the test records. Everything seems to work as expected.

But when I try to use the child specification defined in the test in a standalone example, I can’t play the output video.

To reproduce the problem, save the following code into a file example.exs.

example.exs

Mix.install([
  {:membrane_camera_capture_plugin, "~> 0.4.0"},
  {:membrane_h264_ffmpeg_plugin, "~> 0.21"},
  {:membrane_file_plugin, "~> 0.10"},
  {:membrane_ffmpeg_swscale_plugin, "~> 0.10"}
])

defmodule VideoRecorder 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

{:ok, _supervisor_pid, pipeline_pid} = Membrane.Pipeline.start_link(__MODULE__, [], name: VideoRecorder)
Process.sleep(2000)
VideoRecorder.terminate(pipeline_pid)

Then run the above file with elixir example.exs, and open the outputted video with ffplay output.h264.

Instead of seeing a video, I get the following warning…

[h264 @ 0x15b00a190] Format h264 detected only with low score of 1, misdetection possible!
[h264 @ 0x15b00a190] Could not find codec parameters for stream 0 (Video: h264, none): unspecified size
Consider increasing the value for the 'analyzeduration' (0) and 'probesize' (5000000) options

Any ideas what I’m missing?

Most Liked

jerzywilczek

jerzywilczek

Membrane Core Team

I believe that you need to return the playback: :playing action from your handle_init after the spec action, like this:

{[spec: structure, playback: :playing], %{}}

Last Post!

itsok

itsok

That was it! Thank you for your help.

Where Next?

Popular in Discussions Top

CharlesO
Erlang :list.nth simple, but 1 - based nth(1, [H|_]) -> H; nth(N, [_|T]) when N > 1 -> nth(N - 1, T). Elixir Enum.at … coo...
New
AstonJ
If a newbie asked you about Phoenix Contexts, how would you explain the basics to them? Feel free to be as concise or in-depth as you li...
New
AstonJ
I’ve just started the Phoenix part of the utterly brilliant online course by @pragdave. On generating the Phoenix app he uses the --no-ec...
New
AstonJ
If so I (and hopefully others!) might have some tips for you :slight_smile: But first, please say which area you’re finding most challen...
New
eteeselink
Hi all, In the last days, two things happened: A blog post titled “They might never tell you it’s broken” made the rounds. It’s about ...
New
owaisqayum
I have a sample string sentence = "Hello, world ... 123 *** ^%&*())^% %%:>" From this string, I want to only keep the integers, ...
New
fireproofsocks
I’ve been working on an Elixir project that has required a lot of scripting. I usually reach for Elixir because I like it more (and in th...
New

Other popular topics Top

vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 54006 488
New
lanycrost
Hi everyone! I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
dogweather
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something… Haskell reminds me of Java, and e...
New
romenigld
I am trying to run a deploy with docker and I successfully runned with this command: docker build -t romenigld/blog-prod . but when I t...
New

We're in Beta

About us Mission Statement