AIMC Media icon

AIMC Media

Media operations using FFmpeg.

Compress

AI-generated

Summary

Compress media using FFmpeg with configurable CRF, preset, and output format.

Inputs

  • inputMode — How to provide the input file: Binary, File Path, or URL
  • binaryProperty — Binary property name for input data (default: data)
  • inputFilePath — Local file path to the input media
  • inputUrl — URL to download the input media
  • outputMode — Output type: Binary or File Path
  • outputBinaryProperty — Binary property name for output data (default: data)
  • outputFilePath — File path for the output file
  • outputFormat — Target container format (e.g., mp4, webm, mp3)
  • customOutputFormat — Custom format string when outputFormat is Custom
  • videoCrf — Constant Rate Factor for video quality (0‑51)
  • videoPreset — Encoding preset (e.g., medium)
  • audioBitrate — Audio bitrate for compressed audio
  • additionalOutputOptions — Additional FFmpeg command‑line options, one per line

Output shape

array of objects each containing operation metadata and optionally binary data or outputPath

Binary output is returned as a binary property; file output path is included when outputMode is 'filePath'; always returns an array

Examples

Example 1: Compress a local MP4 file to a smaller MP4 using CRF 22 and medium preset

inputMode=filePath, inputFilePath=/videos/source.mp4, outputMode=filePath, outputFilePath=/videos/output.mp4, outputFormat=mp4, videoCrf=22, videoPreset=medium, audioBitrate=128k

Example 2: Download a video from a URL and compress to WebM with custom scaling option

inputMode=url, inputUrl=https://example.com/video.mp4, outputMode=filePath, outputFormat=webm, additionalOutputOptions=-vf scale=1280:-2

Example 3: Compress two binary streams (video and audio) and merge them into a single binary output

inputMode=binary, binaryProperty=data, outputMode=binary, outputBinaryProperty=data, operation=merge

Links

Discussion