Skip to content

Commit

Permalink
Init ffmpeg container
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmetoner committed Feb 16, 2025
0 parents commit 08df4c1
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 0 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Publish Docker Image
on:
push:
tags:
- '*'

env:
DOCKER_USER: ${{secrets.DOCKER_USER}}
DOCKER_PASSWORD: ${{secrets.DOCKER_PASSWORD}}
CONTAINER_NAME: ${{secrets.CONTAINER_NAME}}

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up QEMU
uses: docker/setup-qemu-action@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: true
build-args: |
FFMPEG_VERSION=${{ github.ref_name }}
tags: |
${{ env.DOCKER_USER }}/${{ env.CONTAINER_NAME }}:latest
${{ env.DOCKER_USER }}/${{ env.CONTAINER_NAME }}:${{ github.ref_name }}
44 changes: 44 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
FROM debian:bookworm-slim

ARG FFMPEG_VERSION

RUN export DEBIAN_FRONTEND=noninteractive \
&& apt-get -qq update \
&& apt-get -qq install --no-install-recommends \
build-essential \
git \
pkg-config \
yasm \
ca-certificates \
gcc \
python3-dev \
&& rm -rf /var/lib/apt/lists/*

RUN git clone https://github.com/FFmpeg/FFmpeg.git --depth 1 --branch ${FFMPEG_VERSION} --single-branch /FFmpeg-${FFMPEG_VERSION}

WORKDIR /FFmpeg-${FFMPEG_VERSION}

RUN ./configure \
--prefix="/usr/local" \
--pkg-config-flags="--static" \
--extra-cflags="-I/usr/local/include" \
--extra-ldflags="-L/usr/local/lib" \
--extra-libs="-lpthread -lm" \
--ld="g++" \
--disable-doc \
--disable-htmlpages \
--disable-podpages \
--disable-txtpages \
--disable-network \
--disable-autodetect \
--disable-hwaccels \
--disable-ffprobe \
--disable-ffplay \
--enable-filter=copy \
--enable-protocol=file \
--enable-small && \
make -j$(nproc) && \
make install && \
hash -r

ENTRYPOINT ["ffmpeg"]
21 changes: 21 additions & 0 deletions LICENCE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2025 Ahmet Oner

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
74 changes: 74 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
# FFmpeg Container

A lightweight Docker container for running FFmpeg commands.

This container provides a ready-to-use FFmpeg environment for video and audio processing. It's built on Alpine Linux to maintain a small footprint while including common FFmpeg codecs and tools.

## Usage

Pull and run the container:

```shell
docker pull onerahmet/ffmpeg
docker run --rm -v "$(pwd):/workspace" onerahmet/ffmpeg -i input.mp4 output.mp4
```

The `-v "$(pwd):/workspace"` flag mounts your current directory to `/workspace` inside the container, allowing FFmpeg to access your local files.

### Example Commands

1. Convert video format:

```shell
docker run --rm -v "$(pwd):/workspace" onerahmet/ffmpeg -i input.mp4 output.mkv
```

2. Extract audio from video:

```shell
docker run --rm -v "$(pwd):/workspace" onerahmet/ffmpeg -i input.mp4 -vn -acodec libmp3lame output.mp3
```

3. Compress video:

```shell
docker run --rm -v "$(pwd):/workspace" onerahmet/ffmpeg -i input.mp4 -c:v libx264 -crf 23 -preset medium -c:a aac output.mp4
```

4. Create video thumbnail:

```shell
docker run --rm -v "$(pwd):/workspace" onerahmet/ffmpeg -i input.mp4 -ss 00:00:01 -vframes 1 -q:v 2 thumbnail.jpg
```

## Building the Container

The container requires specifying an FFmpeg version during build:

```shell
docker build --build-arg FFMPEG_VERSION=n7.1 -t onerahmet/ffmpeg:7.1 .
```

Available versions can be found in [FFmpeg's release tags](https://github.com/FFmpeg/FFmpeg/tags). For example:

- n7.1
- n6.0

Note: The `FFMPEG_VERSION` build argument is required. The build will fail if not provided.

## Features

- Based on Alpine Linux for minimal image size (~120MB)
- Includes common FFmpeg codecs and tools
- Simple volume mounting for file access
- Supports all standard FFmpeg commands and options

## Notes

- All commands are run from the `/workspace` directory inside the container
- Input and output files must be accessible in the mounted volume
- Use absolute paths or paths relative to the mounted directory

## License

This project is licensed under the MIT License - see the LICENSE file for details.

0 comments on commit 08df4c1

Please sign in to comment.