CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-fluent-ffmpeg

A fluent API to FFMPEG for audio and video manipulation with chainable methods

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

input-management.mddocs/

Input Management

Input management capabilities for configuring source files, streams, formats, and processing parameters in fluent-ffmpeg.

Capabilities

Input Source Configuration

Add input files or streams to the FFmpeg command.

/**
 * Add input file or stream to command
 * @param source - File path or readable stream
 * @returns FfmpegCommand instance for chaining
 */
input(source) // → FfmpegCommand
// Aliases: addInput, mergeAdd

Usage Examples:

const ffmpeg = require('fluent-ffmpeg');

// File input
ffmpeg('video.mp4').save('output.mp4');

// Stream input
const fs = require('fs');
const inputStream = fs.createReadStream('input.avi');
ffmpeg(inputStream).save('output.mp4');

// Multiple inputs
ffmpeg()
  .input('video1.mp4')
  .input('video2.mp4')
  .input('audio.mp3')
  .save('combined.mp4');

Input Format Specification

Specify the format of input files when FFmpeg cannot auto-detect.

/**
 * Specify input format for the last added input
 * @param format - Input format name (e.g., 'avi', 'mov', 'rawvideo')
 * @returns FfmpegCommand instance for chaining
 */
inputFormat(format) // → FfmpegCommand
// Aliases: withInputFormat, fromFormat

Usage Examples:

// Raw video input
ffmpeg('rawvideo.yuv')
  .inputFormat('rawvideo')
  .inputFps(25)
  .size('640x480')
  .save('output.mp4');

// Specify format for ambiguous files
ffmpeg('data.bin')
  .inputFormat('h264')
  .save('output.mp4');

Input Frame Rate

Set frame rate for raw video inputs or override detected frame rate.

/**
 * Set input frame rate (for raw video formats)
 * @param fps - Input frames per second
 * @returns FfmpegCommand instance for chaining
 */
inputFps(fps) // → FfmpegCommand
// Aliases: withInputFps, withInputFPS, withFpsInput, withFPSInput, 
//          inputFPS, fpsInput, FPSInput

Usage Examples:

// Raw video with specific FPS
ffmpeg('raw_video.yuv')
  .inputFormat('rawvideo')
  .inputFps(30)
  .size('1920x1080')
  .save('output.mp4');

// Override detected frame rate
ffmpeg('variable_fps.avi')
  .inputFps(25)
  .save('constant_fps.mp4');

Native Frame Rate

Use the native frame rate of the input without conversion.

/**
 * Use native framerate for input (no frame rate conversion)
 * @returns FfmpegCommand instance for chaining
 */
native() // → FfmpegCommand
// Aliases: nativeFramerate, withNativeFramerate

Usage Example:

// Preserve original frame rate
ffmpeg('variable_fps_video.mp4')
  .native()
  .videoCodec('libx264')
  .save('output.mp4');

Input Seeking

Set the starting position for input processing.

/**
 * Set input seek time (start processing from specific position)
 * @param seek - Time in seconds or '[hh:[mm:]]ss[.xxx]' format
 * @returns FfmpegCommand instance for chaining
 */
seekInput(seek) // → FfmpegCommand
// Aliases: setStartTime

Usage Examples:

// Seek to 30 seconds
ffmpeg('long_video.mp4')
  .seekInput(30)
  .duration(60)  // Take 60 seconds from that position
  .save('clip.mp4');

// Seek using time format
ffmpeg('movie.mkv')
  .seekInput('01:30:00')  // Start at 1 hour 30 minutes
  .save('from_middle.mp4');

// Precise seeking with milliseconds
ffmpeg('video.mp4')
  .seekInput('00:02:30.500')  // 2 minutes 30.5 seconds
  .save('precise_clip.mp4');

Input Looping

Configure input looping for continuous processing.

/**
 * Loop over input (repeat input stream)
 * @param duration - Optional loop duration
 * @returns FfmpegCommand instance for chaining
 */
loop(duration?) // → FfmpegCommand

Usage Examples:

// Loop indefinitely until other constraints stop it
ffmpeg('short_clip.mp4')
  .loop()
  .duration(300)  // Loop for 5 minutes total
  .save('looped_output.mp4');

// Loop with specific duration
ffmpeg('logo.png')
  .loop(60)  // Loop the image for 60 seconds
  .fps(25)
  .save('logo_video.mp4');

Custom Input Options

Add custom FFmpeg input options not covered by other methods.

/**
 * Add custom input options
 * @param options - Option string(s) or array of option strings
 * @returns FfmpegCommand instance for chaining
 */
inputOptions(...options) // → FfmpegCommand
// Aliases: addInputOption, addInputOptions, withInputOption, 
//          withInputOptions, inputOption

Usage Examples:

// Hardware decoding
ffmpeg('input.mp4')
  .inputOptions([
    '-hwaccel', 'cuda',
    '-hwaccel_output_format', 'cuda'
  ])
  .save('output.mp4');

// Custom pixel format
ffmpeg('input.yuv')
  .inputOptions('-pix_fmt', 'yuv420p')
  .inputFormat('rawvideo')
  .save('output.mp4');

// Multiple custom options
ffmpeg('rtsp://camera.local/stream')
  .inputOptions([
    '-rtsp_transport', 'tcp',
    '-fflags', '+genpts',
    '-thread_queue_size', '512'
  ])
  .save('recorded.mp4');

Input Types

/**
 * Supported input source types
 */
type InputSource = string | ReadableStream;

/**
 * Input format names (common examples)
 */
type InputFormat = 
  | 'avi' | 'mp4' | 'mkv' | 'mov' | 'wmv' | 'flv'     // Video containers
  | 'mp3' | 'aac' | 'wav' | 'flac' | 'ogg'           // Audio formats  
  | 'rawvideo' | 'yuv4mpegpipe' | 'image2'           // Raw/image formats
  | 'h264' | 'hevc' | 'mpeg2video'                   // Video codecs
  | string;                                           // Any FFmpeg format

/**
 * Time specification formats
 */
type TimeSpec = number | string; // Seconds as number or 'HH:MM:SS.mmm' format

docs

audio-processing.md

configuration.md

index.md

input-management.md

output-management.md

processing-control.md

special-features.md

video-processing.md

tile.json