Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Alternative API to add arguments sequentially, instead of Builder pattern #39

Open
talklittle opened this issue Jul 17, 2022 · 0 comments

Comments

@talklittle
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant