peggy
A module for utilizing FFmpeg in Gleam. It requires that you have FFmpeg in your path. This modules contains the tools for building FFmpeg commands in a type-safe manner appropriate for video services written in this wonderful language.
Types
A CLI argument provided to FFmpeg
pub type CmdOption {
  CmdOption(name: String, value: String)
  Flag(flag: String)
}
      
      Constructors
- 
          
CmdOption(name: String, value: String) - 
          
Flag(flag: String) 
Command provided to FFmpeg
pub type Command {
  Command(
    files: List(File),
    options: List(CmdOption),
    config: Cfg,
  )
}
      
      Constructors
- 
          
Command(files: List(File), options: List(CmdOption), config: Cfg) 
Constants
pub const default_cfg: Cfg
    
  Functions
pub fn add_arg(
  cmd: Command,
  name: String,
  value: String,
) -> Command
    
    Adds argument to command
pub fn allow_recast(cmd: Command) -> Command
    
    Allow forcing a decoder of a different media type than the one detected or designated by the demuxer.
CMD: -recast_media
pub fn aspect_ratio(cmd: Command, ratio: String) -> Command
    
    Set aspect ratio
CMD: -aspect 
pub fn audio_bitrate(cmd: Command, rate: String) -> Command
    
    Set audio bitrate
CMD: -b:a 
pub fn audio_codec(cmd: Command, codec: String) -> Command
    
    Specify audio codec
use ‘copy’ to copy stream
CMD: -c:a <audio_codec>
pub fn audio_filter(cmd: Command, filter: String) -> Command
    
    Apply filter to audio
CMD: -af 
pub fn audio_frame_rate(cmd: Command, rate: String) -> Command
    
    Set audio frame rate
CMD: -s 
pub fn audio_quality(cmd: Command, quality: String) -> Command
    
    Set audio quality
This configuration is codec-specific
CMD: -aq 
pub fn codec(cmd: Command, codec: String) -> Command
    
    Specify codec
use ‘copy’ to copy stream
CMD: -c 
pub fn duration(cmd: Command, duration: String) -> Command
    
    Specifies duration to read/write from/to input/output Arg given before input -> duration of input Arg given after input -> duration of output
This argument takes precedent over until (-to)
CMD: -t 
pub fn err_rate(cmd: Command, rate: Float) -> Command
    
    Set maximum error rate 0.0 -> No errors 1.0 -> All errors
CMD: -max_err_rate 
pub fn exec_sync(cmd: Command) -> Result(String, String)
    
    Executes the command provided to ffmpeg
pub fn frame_rate(cmd: Command, rate: String) -> Command
    
    Set video frame rate
CMD: -s 
pub fn frame_rate_max(cmd: Command, rate: String) -> Command
    
    Set frame size
CMD: -s 
pub fn limit_size(cmd: Command, size: Int) -> Command
    
    Limit size of output file to a set number of bytes
CMD: -fs 
pub fn loop(cmd: Command, loops: Int) -> Command
    
    Specify format of output 0 -> No loop -1 -> Infinite loop
CMD: -stream_loop 
pub fn metadata(cmd: Command, metastring: String) -> Command
    
    Add metadata to output
Usage
peggy.new_command() |> peggy.input(“input.mp4”) |> peggy.metadata(“description = "awesome video"”) |> peggy.metadata(“"filmed by" = "some person"”) |> peggy.output(“output.mp4”) |> peggy.exec_sync()
CMD: -metadata <key=value>
pub fn no_overwrite(cmd: Command) -> Command
    
    Do not overwrite the output file if exists. If the output file already exists, you will get an error
CMD: -n
pub fn num_audio_frames(cmd: Command, num: String) -> Command
    
    Set number of audio frames
CMD: -frames 
pub fn num_frames(cmd: Command, num: String) -> Command
    
    Set number of frames
CMD: -frames 
pub fn num_video_frames(cmd: Command, num: String) -> Command
    
    Set number of video frames
CMD: -frames 
pub fn seek(cmd: Command, pos: Int) -> Command
    
    Seek position in input or output Arg given before input -> seek in input Arg given after input -> seek in output
CMD: -ss 
pub fn seek_eof(cmd: Command, pos: Int) -> Command
    
    Seek position in input or output relative to EOF Position should be negative in this case (0 is EOF) Arg given before input -> seek in input Arg given after input -> seek in output
CMD: -sseof 
pub fn subtitle_codec(cmd: Command, codec: String) -> Command
    
    Set subtitle codec
‘copy’ to copy stream
CMD: -c:s 
pub fn until(cmd: Command, stamp: String) -> Command
    
    Specifies location to stop reading/writing at Arg given before input -> duration of input Arg given after input -> duration of output
CMD: -to 
pub fn video_bitrate(cmd: Command, rate: String) -> Command
    
    Set video bitrate
CMD: -b:v 
pub fn video_codec(cmd: Command, codec: String) -> Command
    
    Specify video codec
use ‘copy’ to copy stream
CMD: -c:v <video_codec>
pub fn video_filter(cmd: Command, filter: String) -> Command
    
    Apply filter to video
CMD: -vf