Skip to main content

Prerequisites

Build configuration

Add the FFmpeg build extension to your trigger.config.ts. This ensures FFmpeg is available in the deployed container:
trigger.config.ts
Build extensions customize the build process and the container image used when deploying tasks. You’ll also need @trigger.dev/build in your devDependencies.
If you use fluent-ffmpeg, add it to external in your config to prevent it from being bundled:
trigger.config.ts

Example 1: Compress a video

This task fetches a video from a URL, compresses it using H.264 with reduced resolution and bitrate, then uploads the result to Cloudflare R2.
trigger/ffmpeg-compress-video.ts
Test payload:

Example 2: Extract audio from a video

This task extracts the audio track from a video, converts it to PCM WAV format, and uploads it to R2.
The video must contain an audio track. If it doesn’t, the task will fail at the FFmpeg step.
trigger/ffmpeg-extract-audio.ts
Test payload:

Example 3: Generate a thumbnail

This task captures a single frame from the 5-second mark of a video and uploads the JPEG thumbnail to R2.
trigger/ffmpeg-generate-thumbnail.ts
Test payload:

Local development

When running locally with trigger.dev dev, build extensions are not applied. You need FFmpeg installed directly on your machine: