ffmpeg
The ffmpeg module wraps the system ffmpeg/ffprobe binaries (which must be
installed). Each call spawns a process — fine for transcode and conversion
jobs. probe returns the full ffprobe output as a navigable object. Import it
with import ffmpeg.
Functions
| Function | Signature | Description |
|---|---|---|
transcode | ffmpeg.transcode(in: string, out: string, opts?) → bool | Transcode a file |
extractAudio | ffmpeg.extractAudio(in: string, out: string, codec?: string) → bool | Extract the audio track |
extractFrames | ffmpeg.extractFrames(in: string, pattern: string, fps?: int) → bool | Write frames to numbered files |
thumbnail | ffmpeg.thumbnail(in: string, out: string, atSeconds?) → bool | Single PNG/JPG snapshot |
probe | ffmpeg.probe(path: string) → object | Metadata: {duration, format, size, streams: [{type, codec, width, height, bitrate, ...}]} |
version | ffmpeg.version() → string | The ffmpeg banner’s first line |
Example
import ffmpeg
let info = ffmpeg.probe("clip.mov")
println(info.duration)
println(info.streams[0].codec)
ffmpeg.transcode("clip.mov", "clip.mp4")
ffmpeg.thumbnail("clip.mov", "poster.jpg", 2)