ffmpex
ffmpex copied to clipboard
Alternative API to add arguments sequentially, instead of Builder pattern
The current API is a Builder, where files are added to the Command builder, and then Streams and Options are added to each file. This is the reverse of the ffmpeg command-line API, where options are specified before the corresponding file.
Current way:
command =
FFmpex.new_command
|> add_global_option(option_y())
|> add_input_file("input.avi")
|> add_output_file("output.avi")
|> add_stream_specifier(stream_type: :video)
|> add_stream_option(option_b("64k"))
|> add_file_option(option_bufsize("64k"))
Corresponds to:
$ ffmpeg -y -i input.avi -b:v 64k -bufsize 64k output.avi
New alternative:
In some situations a more direct mapping of the command-line API to Elixir may be desirable instead of the Builder. It would essentially be a wrapper around Elixir's System.cmd/3
(or Rambo.run/3
) with some convenience functions.
Maybe FFmpex.new_raw_command/0
and a RawCommand
struct and add_raw_argument/2
?
raw_command =
FFmpex.new_raw_command
|> add_raw_argument("-y")
|> add_raw_argument(["-i", "input.avi"])
|> add_raw_argument(["-b:v", "64k"])
|> add_raw_argument(["-bufsize", "64k"])
|> add_raw_argument("output.avi")
Related: #28