kens
Hi, I use m3u8 to live stream audio, I use ffmpeg to convert from webrtc to m3u8. but some reason ffm (port not avaiable) can not start or it die when running. I want to Rerun it again with other port.
I use Supervisor and GenServer to do it. here my code:
defmodule FFmpeg.Supervisor do
use Supervisor
def start_link do
Supervisor.start_link(__MODULE__, [])
end
def init(_) do
children = [
worker(FFmpeg.Service, [])
]
supervise(children, [strategy: :one_for_one])
end
end
defmodule FFmpeg.Service do
use GenServer
def init(:ok) do
{:ok, :ok}
end
def start_link do
GenServer.start_link(__MODULE__, :ok, name: __MODULE__)
end
def start_ffmpeg(room) do
GenServer.call(__MODULE__, {:check, room})
end
def handle_call({:check, room}, _from, state) do
exec = "ffmpeg -analyzeduration 300M -probesize 300M -i #{sdp_file} -strict -2 -c:a aac -ar 16k -ac 1 -preset ultrafast -tune zerolatency -f flv #{path_rtmp_janus}/stream_#{room.id} -nostdin -nostats >/dev/null 2>&1 &"
Port.open({:spawn, exec}, [:binary]) # how to RERUN if it die
IO.inspect "========= END run ffmpeg =============="
{:reply, :ok}
end
end
and run by:
if !Process.whereis(FFmpeg.Service) do
FFmpeg.Supervisor.start_link()
end
FFmpeg.Service.start_ffmpeg(room)
Trending in Questions
Hey guys,
I’ve got a huge CSV ( around 10 GB ) that needs to be processed hourly
Do you guys have any suggestions what is the best prac...
New
Hello!
Could someone please give me a help/sample code, how to delete a file from s3 using waffle/waffle_ecto from Phoenix app.
I creat...
New
I have what I’ve heard referred to as a “lookup table” in my database. This is a way of assigning codes to common values. One common lo...
New
What approach to take when sending live updates to “random” users Hi! I have a question, I have a little chat app, and when I create a DM...
New
Anyone here using Honeybadger?
My Honeybadger account is being overwhelmed with noise from some bots. Seeing a lot of
Bandit.HTTPError...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hobbes is a low-level distributed database for the Elixir programming language.
Hobbes provides a simple, safe, and scalable storage lay...
New
ExRatatui lets you cook up rich terminal UIs in Elixir, powered by Rust’s ratatui via Rustler NIFs. Build interactive terminal applicatio...
New
Hello everyone. After busy few months I am happy to announce v0.1.0 of Emerge & Solve.
They are GUI (Emerge) and State management (S...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
There are three potential reasons for members of this forum to have a look at https://vutuv.de
You are tired or annoyed of LinkedIn.
Yo...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #blog-post
- #elixir-ls
- #ai
- #elixirconf-us
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming











Showing Posts 1 to 7- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
tty
Typically we would do the following: Port.open returns a port(). You can monitor this port() using Port.monitor/1
If ffmpeg dies it will send a {:DOWN, ref, :port, object, reason} to GenServer.handle_info allowing you to act on it.
kens
I added this code:
it always run to :DOWN with reason :normal, I change
execquery to error it continue run the sametty
Can you force ffmpeg to terminate unexpectedly to see if the “reason” changes ?
kens
I try it, but it same, I change wrong command to exec, but it not change reason
tty
Given this you might have to call a shell script which exec ffmpeg. The shell script can traps it dying unexpectedly and returning an error code if that occurs.
OvermindDL1
erlexec or porcelain can do that for you as well with their helper addons.
kens
I am wrong with command, I remove
>/dev/null 2>&1 &and it work