cgrimmett

cgrimmett

Creating a Membrane Framework pipeline for converting a .ts file to a HLS playlist

I would like to create a HLS playlist that I can upload to S3 and serve adaptive bitrate video to visitors. To achieve this, I want to create an Oban worker which takes the URL of a .ts file as input, and outputs a URL of a .m3u8 playlist. The playlist would then get embedded into Heex in my Phoenix app.

I found another post with some code from 2-3 years ago which does what I want, but the dependent Membrane framework library membrane_mpegts_plugin hasn’t been updated in 4 years and isn’t compatible with membrane_core 1.1.2.

I really need to work with .ts files so I figured I’d update membrane_mpegts_plugin. Thankfully, membrane_core has a good changelog and upgrade guides which outline what needs to change in the plugin. I’ve spent two days on the task and I’ve made lots of progress, but I’ve ran into a testing error that I’m having trouble understanding and working through.

  1) test Demuxer works in a Pipeline that defines links statically in its init (Membrane.MPEG.TS.IntegrationTest)
     test/mpeg_ts/integration_test.exs:13
     Assertion failed, no matching message after 2000ms
     Showing 2 of 2 messages in the mailbox
     code: assert_receive {Membrane.Testing.Pipeline, ^pid_value, {:handle_element_start_of_stream, {:audio_out, :input}}}
     mailbox:
       pattern: {
                  Membrane.Testing.Pipeline,
                  ^pid_value,
                  {
                    :handle_element_start_of_stream,
                    {:audio_out, :input}
                  }
                }
       value:   {Membrane.Testing.Pipeline, #PID<0.278.0>, :setup}

       pattern: {
                  Membrane.Testing.Pipeline,
                  ^pid_value,
                  {
                    :handle_element_start_of_stream,
                    {:audio_out, :input}
                  }
                }
       value:   {Membrane.Testing.Pipeline, #PID<0.278.0>, :play}
     stacktrace:
       test/mpeg_ts/integration_test.exs:34: Membrane.MPEG.TS.IntegrationTest.perform_integration_test/1
       test/mpeg_ts/integration_test.exs:14: (test)

https://github.com/insanity54/membrane_mpegts_plugin/commit/d6970c7c7dc8638272fe39197e2859fa20ab0971#diff-ec715e3216845119e910515ecdae108b3e958e265b48838d2256de489b063fc8R34

I’m struggling to understand why the shape of the pattern { Membrane.Testing.Pipeline, ^pid_value, { :handle_element_start_of_stream, {:audio_out, :input} } } is so different from the value {Membrane.Testing.Pipeline, #PID<0.278.0>, :play}. How come the pattern has a tuple after ^pid_value,, whereas the value has a :play atom after the PID? Normally this is where I would look at the code in the stack trace, but in this case there isn’t any file beyond integration_test.exs which I’m already familiar with.

I tried configuring ExUnit to show more stacktrace by setting :stacktrace_depth to 50, but that didn’t give me any more lines than the 2 I already see.

I’m hoping for some outside perspective to help get me back on track.

Most Liked

varsill

varsill

Membrane Core Team

Hello @cgrimmett !
I think it might be easier for you to use: GitHub - kim-company/membrane_mpeg_ts_plugin: Membrane.Filter that demuxes MPEG-TS streams · GitHub which is a plugin containing MPEG-TS demuxer, maintained by a third party. This one is up to date with membrane_core v1.1 and it’s undergoing active development.
For the list of actively maintained plugins you can take a look here: GitHub - membraneframework/membrane_core: The core of Membrane Framework, multimedia processing framework written in Elixir · GitHub

Sorry for confusion, I think we should have deprecated that old membrane_mpegts_plugin package on Hex as I don’t think we plan to maintain it anymore.

I really appreciate you work on updating the plugin, I know how exhausting it can be!

If you would like to continue on updating membrane_mpegts_plugin, I can try to help with this one (but I definitely recommend trying the third party plugin).
It seems that for some reason buffers are not flowing in the pipeline. I suspect that it might have something to do with the fact, that now the default flow_control for both input and output pads in the filter is :auto and not :manual, as it used to be. It means that the logic in handle_demand nor sending :demand actions work at all.

cgrimmett

cgrimmett

Oh thank you! I didn’t realize there was another mpeg-ts library. I will use that one instead.

Where Next?

Popular in Questions 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
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
stefanchrobot
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
komlanvi
Hi everyone, I was playing with phoenix liveView but I run into an issue. I have a form and want to validate each input text when the te...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
jerry
Good day to you all. I have been struggling to get a query involving like and ilike to work. Can anyone assist me on this, please? pro...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New

Other popular topics Top

nobody
Hi! In PHP: $_SERVER[‘SERVER_ADDR’] - in Elixir? Searched the docs for ip address and the web, no good results. Thanks!
New
hariharasudhan94
Lets say I have map like this fetching from my database %{"_id" =&gt; #BSON.ObjectId&lt;58eb1a7a9ad169198c3dXXXX&gt;, "email" =&gt; ...
New
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
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
AngeloChecked
What learn first? Rust or Elixir Hi Elixir community! I’m here because i want learn a new language. I’m a junior developer and mainly i ...
New

We're in Beta

About us Mission Statement