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!

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

senggen
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1] 15:22:35.803 [error] gen_event {lager_file_backend...
New
sergio
In Ruby, I can go: User.find_by(email: "foobar@email.com").update(email: "hello@email.com") How can I do something similar in Elixir? ...
New
Tee
can someone please explain to me how Enum.reduce works with maps
New
LegitStack
I’m hoping you guys can give me some general advice and perhaps code examples if you’re feeling up to it. I’m very interested in Elixir,...
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 record...
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
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
wernerlaude
In AR this is so simple @articles = current_user.articles How to do in Ecto? def index(conn, _params) do current_user = conn.assig...
New
siddhant3030
Hi, I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
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

Other popular topics Top

vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
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
AstonJ
You’re a programmer, so you don’t need spoon feeding with the conventional drivel about “this is an integer.” No. You need to know what’s...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 35421 110
New
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
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
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
lucidguppy
I have a super simple question about elixir - how would I take a file like this foo bar baz and output a new file that enumerates th...
New
TunkShif
This post is an instruction guide to help you setup your Neovim for Elixir development from scratch. It includes general information on h...
273 38985 115
New
magnetic
Hey :wave:t3: Elixir community, I’ve been learning Elixir, and working on some side projects. My editor of choice is VSCode, and althoug...
New

We're in Beta

About us Mission Statement