ffmpex v0.4.1 FFmpex

Create and execute ffmpeg CLI commands.

The API is a builder, building up the list of options per-file, per-stream(-per-file), and globally.

Note that adding options is backwards from using the ffmpeg CLI; when using ffmpeg CLI, you specify the options before each file. But with FFmpex (this library), you add the file/stream first, then add the relevant options afterward.

Example usage:

import FFmpex
use FFmpex.Options

command =
  FFmpex.new_command
  |> add_global_option(option_y())
  |> add_input_file("/path/to/input.avi")
  |> add_output_file("/path/to/output.avi")
    |> add_stream_specifier(stream_type: :video)
      |> add_stream_option(option_b("64k"))
    |> add_file_option(option_maxrate("128k"))
    |> add_file_option(option_bufsize("64k"))

:ok = execute(command)

Summary

Functions

Add a per-file option to the command. Applies to the most recently added file

Add a global option that applies to the entire command

Add an input file to the command

Add an output file to the command

Add a per-stream option to the command. Applies to the most recently added stream specifier, of the most recently added file

Add a stream specifier to the most recent file. The stream specifier is used as a target for per-stream options

Execute the command using ffmpeg CLI

Begin a new blank (no options) ffmpeg command

Functions

add_file_option(command, option)

Add a per-file option to the command. Applies to the most recently added file.

add_global_option(command, option)

Add a global option that applies to the entire command.

add_input_file(command, file)

Add an input file to the command.

add_output_file(command, file)

Add an output file to the command.

add_stream_option(command, option)

Add a per-stream option to the command. Applies to the most recently added stream specifier, of the most recently added file.

add_stream_specifier(command, opts)
add_stream_specifier(command :: FFmpex.Command.t, opts :: Keyword.t) :: FFmpex.Command.t

Add a stream specifier to the most recent file. The stream specifier is used as a target for per-stream options.

Example:

add_stream_specifier(command, stream_type: :video)

Options:

  • :stream_index - 0-based integer index for the stream
  • :stream_type - One of :video, :video_without_pics, :audio, :subtitle, :data, :attachments
  • :program_id - ID for the program
  • :stream_id - Stream id (e.g. PID in MPEG-TS container)
  • :metadata_key - Match streams with the given metadata tag
  • :metadata_value - Match streams with the given metadata value. Must also specify :metadata_key.
  • :usable - Matches streams with usable configuration, the codec must be defined and the essential information such as video dimension or audio sample rate must be present.
execute(command)
execute(command :: FFmpex.Command.t) ::
  :ok |
  {:error, {Collectable.t, exit_status :: non_neg_integer}}

Execute the command using ffmpeg CLI.

Returns :ok on success, or {:error, {cmd_output, exit_status}} on error.

new_command()

Begin a new blank (no options) ffmpeg command.