flp

flp

Call FFMPEG with Complex Filter from Ports

I’m trying to call FFMPEG with a complex filter from Ports, but despite the command working in my shell, I somehow miss the understanding to get it working in Elixir with ports when combined with a complex filter.

This works in my shell,

ffmpeg -i input.mp4 -filter_complex " [0:a] volume=1 [final_audio]" -map ‘[final_audio]’ output.mp4

but the following in Elixir does not work. It seems to get stuck before the transformation.

ffmpeg = System.find_executable(“ffmpeg”)
ffmpeg_args = [“-i”, “input.mp4”, “-filter_complex”, “[0:a] volume=1 [final_audio]”, “-map”, “[final_audio]”, “-c:v”, “libx264”, “output.mp4”]
Port.open({:spawn_executable, ffmpeg}, [{:args, ffmpeg_args}, :binary, :exit_status, :hide, :use_stdio])

also the following gets stuck:

ffmpeg_args = [“-i”, “input.mp4”, “-filter_complex”, “[0:a]”, “volume=1”, “[final_audio]”, “-map”, “[final_audio]”, “-c:v”, “libx264”, “output.mp4”]

On the other hand, the following works:

ffmpeg = System.find_executable(“ffmpeg”)
ffmpeg_args = [“-i”, “video.mp4”, final_output]
Port.open({:spawn_executable, ffmpeg}, [{:args, ffmpeg_args}, :binary, :exit_status, :hide, :use_stdio])

Marked As Solved

flp

flp

I first wanted to get it working to optimize later so I avoid spending a lot of time for nothing.

Luckily, it’s working now with complex filters.

ffmpeg_args = ~W(-i interception.mp4 -filter_complex [0:a]volume=1[final_audio] -map [final_video] -c:v libx264 final_output.mp4)

Also Liked

cblavier

cblavier

Do you want to keep with bare Elixir or would you mind trying a wrapper?

I remember that when Port was hurting me with stdin handling, I found the rambo lib to be incredibly useful!

https://github.com/jayjun/rambo

eksperimental

eksperimental

I think you can simplify the argument passing by using the ~W/~w sigils.

ffmpeg_args = ~W(-i input.mp4 -filter_complex [0:a] volume=1 [final_audio] -map [final_audio] -c:v libx264 output.mp4)

Where Next?

Popular in Questions Top

Kurisu
For example for a current url like http://localhost:4000/cosmetic/products?_utf8=✓&query=perfume&page=2, I would like to get: ...
New
skosch
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
jononomo
I am trying to figure out how Mix knows whether the environment is test, dev, or prod – where is this set? Thanks.
New
baxterw3b
Hi guys, i’m new in the Elixir world, and i have to say, that i love it! i’m having some problem to understand anonymous functions with ...
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
dotdotdotPaul
Okay, I’m having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I’m sure I’...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New

Other popular topics Top

marius95
Hello everyone, I try to use an Javascript Event Handler in my root.html.leex file. Therefore I created a function in the app.js file: ...
New
albydarned
Hello all! I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
JeremM34
Hello, how can I check the Phoenix version ? Thanks !
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
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
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
marick
I had some trouble figuring out how to make many-to-many associations work. Once I got it working, I wrote a blog post. Because I’m a nov...
New
PeterCarter
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
AstonJ
Seen any cool LiveView demos, sample apps or examples? Please post them here! :003:
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

We're in Beta

About us Mission Statement