Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/kennethwussmann/docker-ffmpeg-converter

Docker service designed to simplify and streamline media conversion tasks
https://github.com/kennethwussmann/docker-ffmpeg-converter

converter docker ffmpeg media pipeline

Last synced: 2 days ago
JSON representation

Docker service designed to simplify and streamline media conversion tasks

Awesome Lists containing this project

README

        


🎬 docker-ffmpeg-converter



Dynamic Docker service designed to simplify and streamline media conversion tasks


## 🌟 Overview
docker-ffmpeg-converter automates the process of file conversion by:
1. **Monitoring** an input directory for new files.
2. **Utilizing** [ffmpeg](https://www.ffmpeg.org/) to perform specified conversion operations.
3. **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.

## 🚀 Deployment

Deploying docker-ffmpeg-converter is a breeze with Docker Compose. Below is an example YAML configuration file:

```YAML
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
```

### 🏷️ Tags

This image is built for `arm64` and `amd64`.

- `latest` - Latest stable release
- `x.x.x` - Specific version under Semver ([See all versions](https://github.com/KennethWussmann/docker-ffmpeg-converter/pkgs/container/docker-ffmpeg-converter/versions))
- `develop` - Unstable pre-release development version

### 🔧 Configuration

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.

## 💼 How the Service Works

### 📂 File Monitoring and Conversion

1. **File Detection**: The service continually polls the `SOURCE_DIRECTORY_PATH`, filtering files using the specified `GLOB_PATTERNS`.
2. **File Verification**: New files are cached and checked for size stability, based on `FILE_UNCHANGED_INTERVALS`.
3. **Conversion**: Stable files are handed to the converter, building an ffmpeg command with `FFMPEG_ARGS`.

Example:
```shell
FFMPEG_ARGS=-y -fflags +genpts -i %s -r 24 %s.mp4
SOURCE_DIRECTORY_PATH=/data/input
DESTINATION_DIRECTORY_PATH=/data/output
```
Resulting command:
```shell
/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.

4. **Post-Conversion**: Depending on `REMOVE_SOURCE_AFTER_CONVERT`, the source file may be deleted after successful conversion.

### ⏱️ Custom Intervals and Patterns

- **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`.

## 🔗 Pipeline example

Here is a more complex example on how to use mulitple instances:

```YAML
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.

## 🎉 Conclusion
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! 🎬