Dynamic Docker service designed to simplify and streamline media conversion tasks
docker-ffmpeg-converter automates the process of file conversion by:
- Monitoring an input directory for new files.
- Utilizing ffmpeg to perform specified conversion operations.
- Optionally removing the source files post conversion.
Whether you are building a small pipeline or conducting background conversions of multiple files, docker-ffmpeg-converter efficiently handles it all. Run multiple instances and make your conversion process more versatile and robust.
Deploying docker-ffmpeg-converter is a breeze with Docker Compose. Below is an example YAML configuration file:
version: "3.9"
services:
video-converter:
image: ghcr.io/kennethwussmann/docker-ffmpeg-converter:latest
volumes:
# This is where we will add input files and get output files
- ./data:/data
environment:
# See below for all options and their meaning. This is just the required set.
- SOURCE_DIRECTORY_PATH=/data/input
- DESTINATION_DIRECTORY_PATH=/data/output
- GLOB_PATTERNS=*.webm
- FFMPEG_ARGS=-y -fflags +genpts -i %s -r 24 %s.mp4
This image is built for arm64
and amd64
.
latest
- Latest stable releasex.x.x
- Specific version under Semver (See all versions)develop
- Unstable pre-release development version
Configure the container through environment variables. Here's a breakdown of what you can customize:
Variable | Required | Description |
---|---|---|
SOURCE_DIRECTORY_PATH |
Yes | Directory watched for new files |
DESTINATION_DIRECTORY_PATH |
Yes | Directory for converted files |
GLOB_PATTERNS |
Yes | Comma-separated list of glob patterns the service will use to filter files in the SOURCE_DIRECTORY_PATH |
FFMPEG_ARGS |
Yes | Arguments for the ffmpeg binary that specify what to do. See ffmpeg docs. You can use placeholders %s , see below. |
REMOVE_SOURCE_AFTER_CONVERT |
No (default: false ) |
true or false . Whether or not to delete source files after successful conversion |
SCAN_INTERVAL |
No (default: 10 ) |
Interval in seconds when the service will search for new files |
FILE_UNCHANGED_INTERVALS |
No (default: 3 ) |
How many cycles the service will wait for new files to stay unchanged until conversion starts. See below for detailed info. |
- File Detection: The service continually polls the
SOURCE_DIRECTORY_PATH
, filtering files using the specifiedGLOB_PATTERNS
. - File Verification: New files are cached and checked for size stability, based on
FILE_UNCHANGED_INTERVALS
. - Conversion: Stable files are handed to the converter, building an ffmpeg command with
FFMPEG_ARGS
.
Example:
FFMPEG_ARGS=-y -fflags +genpts -i %s -r 24 %s.mp4
SOURCE_DIRECTORY_PATH=/data/input
DESTINATION_DIRECTORY_PATH=/data/output
Resulting command:
/usr/bin/ffmpeg -y -fflags +genpts -i /data/input/myfile.webm -r 24 /data/input/myfile.mp4
Note: The order of
%s
is vital. The first represents the source file and the second the destination.
- Post-Conversion: Depending on
REMOVE_SOURCE_AFTER_CONVERT
, the source file may be deleted after successful conversion.
- Scan Interval: Adjust the polling frequency with
SCAN_INTERVAL
, defining the seconds between each search. - File Unchanged Intervals: Customize the number of cycles to wait for file size stability using
FILE_UNCHANGED_INTERVALS
.
Here is a more complex example on how to use mulitple instances:
version: "3.9"
services:
# Same as above
webm-to-mp4:
image: ghcr.io/kennethwussmann/docker-ffmpeg-converter:latest
volumes:
# This is where we will add input files and get output files
- ./data:/data
environment:
- SOURCE_DIRECTORY_PATH=/data/input
- DESTINATION_DIRECTORY_PATH=/data/output
- GLOB_PATTERNS=*.webm
# Convert *.webm files to .mp4
- FFMPEG_ARGS=-y -fflags +genpts -i %s -r 24 %s.mp4
# Another instance to take thumbnails from the *.webm files
webm-thumbnails:
image: ghcr.io/kennethwussmann/docker-ffmpeg-converter:latest
volumes:
- ./data:/data
environment:
- SOURCE_DIRECTORY_PATH=/data/input
- DESTINATION_DIRECTORY_PATH=/data/output
- GLOB_PATTERNS=*.webm
# Take multiple thumbnails from *.webm files
- FFMPEG_ARGS=-y -i %s -vf fps=1/4 %s_%04d.png
The output directory will then contain multiple thumbnails and a converted MP4 file of our source material. Because the containers run in parallel they finish quickly as both tasks can run simulatanously.
docker-ffmpeg-converter is a great solution for seamless media conversion tasks, providing robust customization and a simplified deployment process. Experience the ease of automation with this powerful Docker service.
Feel free to explore, contribute, or seek support. Happy converting! 🎬