akash-akya / ex_cmd

ExCmd is an Elixir library to run external programs and to communicate with back pressure
MIT License
65 stars 3 forks source link

Add Discussion - A use case of ExCmd #33

Closed ndrean closed 3 months ago

ndrean commented 3 months ago

This is not an issue but I would like to open a discussion on how to use ExCmd.

My use case is:

I currently data = File.read!(path) and pass the data to a process. It is a GenServer that inits Porcelain with a command that runs FFmpeg: indeed, I run the FFmpeg using the stdin buffer, so I need it to be running. FFmpeg is building HLS segments and a playlist.

My interest in ExCmd is that it seems I don't need a GenServer.

I can %Plug.Upload.give_away(FFmpegProcess, path, self()) and just pass the path.

How would you do then? The following does not run. I have no external file to output to since FFmpeg builds the segments and the playlist, passed as arguments in the command.

ExCmd.stream!(__ffmpeg_cmd__, input: File.read!(path))

I tried to add Enum.into("") , but I get {:error, :epipe}.

I did not add a Livebook because I am not familiar with Kino, nor how would I run some Javascript code in a Livebook.