HAH

HAH

Problem converting mp4 to hls

Im trying to create a project with membrane to convert an mp4-file to an hsl. I get this error message:
[error] Mp4ToHls/:parser_audio Error occured in Membrane Element:
** (MatchError) no match of right hand side value: <<64, 20, 0, 24, 0, 0, 1, 244, 0, 0, 1, 244, 0, 5, 128, 128, 128, 2, 17, 144>>

defmodule Mp4ToHls do
  use Membrane.Pipeline
  require Logger

  @input_file "/Users/samy/Desktop/voorstelling.mp4"
  @output_dir "output"

  def start_link(opts \\ []) do
    Membrane.Pipeline.start_link(__MODULE__, opts, name: __MODULE__)
  end

  @impl true
  def handle_init(_ctx, _opts) do
    File.rm_rf!(@output_dir)
    File.mkdir!(@output_dir)

    spec = [
      child(:source, %Membrane.File.Source{
        location: @input_file
      })
      |> child(:demuxer, Membrane.MP4.Demuxer.ISOM),
      get_child(:demuxer)
      |> via_out(:output, options: [kind: :video])
      |> child(:parser_video, %Membrane.H264.Parser{output_stream_structure: :annexb})
      |> via_in(Pad.ref(:input, :video),
        options: [encoding: :H264, segment_duration: Membrane.Time.seconds(4)]
      )
      |> get_child(:hls),
      get_child(:demuxer)
      |> via_out(:output, options: [kind: :audio])
      |> child(:parser_audio, %Membrane.AAC.Parser{})
      |> via_in(Pad.ref(:input, :audio),
        options: [encoding: :AAC, segment_duration: Membrane.Time.seconds(4)]
      )
      |> get_child(:hls),
      child(:hls, %Membrane.HTTPAdaptiveStream.SinkBin{
        manifest_module: Membrane.HTTPAdaptiveStream.HLS,
        target_window_duration: Membrane.Time.seconds(15),
        storage: %Membrane.HTTPAdaptiveStream.Storages.FileStorage{directory: @output_dir}
      })
    ]

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

  @impl true
  def handle_child_notification({:track_playable, _track_info}, :hls, _context, state) do
    Logger.info("HLS playlist is ready.")
    send(:script, :playlist_ready)
    {[], state}
  end

  @impl true
  def handle_child_notification(notification, _element, _ctx, state) do
    Logger.debug("Notification received: #{inspect(notification)}")
    {[], state}
  end
end

First Post!

mat-hek

mat-hek

Membrane Core Team

Hmm, it works fine for me, so I suppose it’s related to the file you’re trying to convert. Can you share it too? Or at least output from ffprobe /Users/samy/Desktop/voorstelling.mp4

Last Post!

mat-hek

mat-hek

Membrane Core Team

Yeah it looks correct, so it may be a bug in the demuxer or parser. Can you provide a full stacktrace?

Where Next?

Popular in Questions Top

rms.mrcs
Hi, I need to transform a list of numbers into a map where the keys are the indexes and the values are the original values of the list. ...
New
electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
openscript
Hello! Sorry for this astonishing simple question, but I’m really stuck. I try to set up the intellij-elixir plugin, but I don’t know ho...
New
Fl4m3Ph03n1x
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: ) Hello all, this is ...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
sen
Hi All, I set a environment variables in dev.exs , like below code. when i start server, how can i set the ${enable} value? thanks. d...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 44139 214
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID&lt;0.412.0&gt; terminating ** (Postgrex.Error) FATAL...
New
Harrisonl
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service. Currently when I de...
New

We're in Beta

About us Mission Statement