Skip to main content
FFmpeg 6.0 or later is required for all video operations.
# Linux
sudo apt install ffmpeg

# macOS
brew install ffmpeg

# Verify installation
ffmpeg -version

VideoTranscodeJob

Transcodes a video file to a different codec, bitrate, or encoding preset. Go method: Client.VideoTranscode(ctx, job)

Parameters

input
string
required
Path to the source video file.
output
string
required
Path for the transcoded output file.
codec
string
Target video codec. Accepted values: h264, h265, vp8, vp9, av1.
bitrate
string
Target video bitrate. Examples: "2M", "5000k". Ignored when crf is set.
preset
string
Encoding speed preset. Accepted values: ultrafast, fast, medium, slow, veryslow. Slower presets produce smaller files at the cost of encoding time.
crf
uint8
Constant Rate Factor for quality-based encoding. Range: 0 (lossless) to 51 (worst). A value of 23 is a good default for H.264.
audio_codec
string
Audio codec for the output file. Examples: "aac", "mp3", "opus".
Use crf for quality-based encoding instead of bitrate when file size is not a hard constraint. CRF produces consistent visual quality regardless of scene complexity, while a fixed bitrate can result in poor quality during complex scenes.

Codec comparison

CodecBest forNotes
h264General useBest browser and device compatibility
h265Storage efficiency~50% better compression than H.264 (HEVC)
vp8WebM / older browsersOpen and royalty-free
vp9WebM / modern browsersBetter compression than VP8
av1Maximum compressionBest quality per bit; slowest to encode

Example

result, err := client.VideoTranscode(ctx, &dpf.VideoTranscodeJob{
    Input:      "video.mp4",
    Output:     "output.mp4",
    Codec:      "h264",      // h264, h265, vp8, vp9, av1
    Bitrate:    "2M",
    Preset:     "medium",    // ultrafast, fast, medium, slow, veryslow
    CRF:        func(u uint8) *uint8 { return &u }(23),
    AudioCodec: "aac",
})
if err != nil {
    log.Fatal(err)
}
log.Printf("Success in %dms", result.ElapsedMs)

VideoResizeJob

Scales a video to specific dimensions, optionally preserving the aspect ratio. Go method: Client.VideoResize(ctx, job)

Parameters

input
string
required
Path to the source video file.
output
string
required
Path for the resized output file.
width
uint32
Target width in pixels. Can be omitted when height is provided and maintain_aspect is true.
height
uint32
Target height in pixels. Can be omitted when width is provided and maintain_aspect is true.
maintain_aspect
boolean
When true, the unspecified dimension is calculated automatically to preserve the original aspect ratio. Defaults to false.

Example

result, err := client.VideoResize(ctx, &dpf.VideoResizeJob{
    Input:          "video.mp4",
    Output:         "video_720p.mp4",
    Width:          1280,
    Height:         720,
    MaintainAspect: true,
})
if err != nil {
    log.Fatal(err)
}
log.Printf("Success in %dms", result.ElapsedMs)

Build docs developers (and LLMs) love