pg_ffmpeg
pg_ffmpeg · Exposes FFmpeg media processing functions inside PostgreSQL through a pgrx extension.
Overview
PostgreSQL · 16, 17, 18
Usage
Sources:
pg_ffmpeg version 0.3.4 exposes FFmpeg 8 media inspection and transformation functions in the fixed ffmpeg schema for PostgreSQL 16–18. Inputs and outputs are commonly whole media objects carried as bytea; the extension also provides transcoding, audio extraction, trimming, frame extraction, HLS, GIF, waveform, subtitle, overlay, filtering, concatenation, and encoding operations.
Inspect a stored upload
FFmpeg parses attacker-controlled binary formats inside the PostgreSQL backend, and media jobs can consume substantial CPU, memory, and temporary storage. Large bytea values and concat_agg can amplify backend memory use. The hls interface can fetch a URL and stores playlists and segments in extension tables, so unrestricted execution can create outbound-request and storage-abuse paths. The upstream filter allowlist blocks several file-reading filters, but that is not a complete trust boundary. Grant execution only to a dedicated workload role, apply statement/resource/network limits, validate media outside PostgreSQL when possible, and never expose server-side file operations to untrusted SQL users.