Video processing with FFmpeg
These examples show you how to process videos in various ways using FFmpeg with Trigger.dev.
Prerequisites
- A project with Trigger.dev initialized
- FFmpeg installed on your machine
Adding the FFmpeg build extension
To use these example tasks, you’ll first need to add our FFmpeg extension to your project configuration like this:
Build extensions allow you to hook into the build system and customize the build process or the resulting bundle and container image (in the case of deploying). You can use pre-built extensions or create your own.
You’ll also need to add @trigger.dev/build
to your package.json
file under devDependencies
if you don’t already have it there.
Compress a video using FFmpeg
This task demonstrates how to use FFmpeg to compress a video, reducing its file size while maintaining reasonable quality, and upload the compressed video to R2 storage.
Key Features
- Fetches a video from a given URL
- Compresses the video using FFmpeg with various compression settings
- Uploads the compressed video to R2 storage
Task code
Testing your task
To test this task, use this payload structure:
Extract audio from a video using FFmpeg
This task demonstrates how to use FFmpeg to extract audio from a video, convert it to WAV format, and upload it to R2 storage.
Key Features
- Fetches a video from a given URL
- Extracts the audio from the video using FFmpeg
- Converts the extracted audio to WAV format
- Uploads the extracted audio to R2 storage
Task code
Testing your task
To test this task, use this payload structure:
Make sure to provide a video URL that contains audio. If the video does not have audio, the task will fail.
Generate a thumbnail from a video using FFmpeg
This task demonstrates how to use FFmpeg to generate a thumbnail from a video at a specific time and upload the generated thumbnail to R2 storage.
Key Features
- Fetches a video from a given URL
- Generates a thumbnail from the video at the 5-second mark
- Uploads the generated thumbnail to R2 storage
Task code
Testing your task
To test this task in the dashboard, you can use the following payload:
Local development
To test this example task locally, be sure to install any packages from the build extensions you added to your trigger.config.ts
file to your local machine. In this case, you need to install .
Was this page helpful?