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

FunctionSignatureDescription
transcodeffmpeg.transcode(in: string, out: string, opts?) → boolTranscode a file
extractAudioffmpeg.extractAudio(in: string, out: string, codec?: string) → boolExtract the audio track
extractFramesffmpeg.extractFrames(in: string, pattern: string, fps?: int) → boolWrite frames to numbered files
thumbnailffmpeg.thumbnail(in: string, out: string, atSeconds?) → boolSingle PNG/JPG snapshot
probeffmpeg.probe(path: string) → objectMetadata: {duration, format, size, streams: [{type, codec, width, height, bitrate, ...}]}
versionffmpeg.version() → stringThe 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)
Standard library · View as Markdown · llms-full.txt