mediaforge - v0.1.0
    Preparing search index...

    Class FFmpegBuilder

    Fluent FFmpeg builder. All methods return this for chaining. Call .run() to execute or .spawn() for event-based control.

    await new FFmpegBuilder('input.mp4')
    .videoCodec('libx264')
    .videoBitrate('2M')
    .audioCodec('aac')
    .output('output.mp4')
    .run();
    Index

    Constructors

    Methods

    • Override the ffmpeg binary path (default: FFMPEG_PATH env or 'ffmpeg')

      Parameters

      • path: string

      Returns this

    • Check if a codec is available in the current binary. Does not throw — returns a GuardResult.

      Parameters

      • codec: string
      • direction: "encode" | "decode" = 'encode'

      Returns GuardResult

    • Check if a feature is available by version gate + capability.

      Parameters

      • featureKey: string

      Returns Promise<GuardResult>

    • Select the best available video codec from a priority list. Returns null if none are available.

      Parameters

      Returns Promise<string | null>

      const codec = await builder.selectVideoCodec([
      { codec: 'h264_nvenc', featureKey: 'nvenc' },
      { codec: 'h264_vaapi' },
      { codec: 'libx264' },
      ]);
      builder.videoCodec(codec ?? 'libx264');
    • Select the best available hardware accelerator from a priority list.

      Parameters

      • candidates: string[]

      Returns string | null

    • Overwrite output files without asking (default: true)

      Parameters

      • yes: boolean = true

      Returns this

    • Enable progress reporting on stderr

      Returns this

    • Seek within the last-added input (fast seek, before -i)

      Parameters

      • position: string | number

      Returns this

    • Limit duration of the last-added input

      Parameters

      • duration: string | number

      Returns this

    • Force format of the last-added input

      Parameters

      • format: string

      Returns this

    • Set video codec, e.g. 'libx264', 'libx265', 'copy'

      Parameters

      • codec: string

      Returns this

    • Set video bitrate, e.g. '2M', '4000k'

      Parameters

      • bitrate: string | number

      Returns this

    • Set video frame rate

      Parameters

      • rate: string | number

      Returns this

    • Set output video size, e.g. '1280x720' or '1280:720'

      Parameters

      • widthXheight: string

      Returns this

    • Set video filter chain (-vf)

      Parameters

      • filter: string

      Returns this

    • Set pixel format

      Parameters

      • fmt: string

      Returns this

    • Set CRF value (codec-dependent)

      Parameters

      • value: number

      Returns this

    • Set audio codec, e.g. 'aac', 'libopus', 'copy'

      Parameters

      • codec: string

      Returns this

    • Set audio bitrate, e.g. '128k', '192k'

      Parameters

      • bitrate: string | number

      Returns this

    • Set audio sample rate, e.g. 44100, 48000

      Parameters

      • rate: number

      Returns this

    • Set number of audio channels

      Parameters

      • channels: number

      Returns this

    • Set audio filter chain (-af)

      Parameters

      • filter: string

      Returns this

    • Set subtitle codec

      Parameters

      • codec: string

      Returns this

    • Force output format

      Parameters

      • format: string

      Returns this

    • Add stream mapping, e.g. '0:v:0', '0:a:1'

      Parameters

      • specifier: string

      Returns this

    • Limit output duration

      Parameters

      • d: string | number

      Returns this

    • Seek in output (re-encode seek, accurate)

      Parameters

      • position: string | number

      Returns this

    • Pass arbitrary extra args for the current output

      Parameters

      • ...args: string[]

      Returns this

    • Pass arbitrary extra args at the global level

      Parameters

      • ...args: string[]

      Returns this

    • Enable hardware acceleration (-hwaccel). Probes version if cached.

      Parameters

      • accel: string
      • Optionalopts: { device?: string }

      Returns this

    • Set -filter_complex string directly (typed DSL coming in Phase 3)

      Parameters

      • filter: string

      Returns this

    • Build and return the full argument array.

      Returns string[]

    • Spawn the process with full event-emitter control. Useful for streaming progress or piping stdout.

      Parameters

      • Optionalopts: { parseProgress?: boolean; totalDurationUs?: number }

      Returns FFmpegProcess

    • Run ffmpeg and return a Promise that resolves on success. Rejects with FFmpegSpawnError on non-zero exit.

      Parameters

      • Optionalopts: { parseProgress?: boolean; totalDurationUs?: number }

      Returns Promise<void>

    • Probe the binary version and return a human-readable string. Also caches the version for subsequent requireVersion() checks.

      Returns Promise<string>