Convert Figma logo to code with AI

jrottenberg logoffmpeg

Docker build for FFmpeg on Ubuntu / Alpine / Centos / Scratch / nvidia / vaapi

1,403
455
1,403
114

Top Related Projects

44,846

Mirror of https://git.ffmpeg.org/ffmpeg.git

The FFmpeg build script provides an easy way to build a static FFmpeg on OSX and Linux with non-free codecs included.

Port of FFmpeg with Emscripten

3,679

The fastest and safest AV1 encoder.

Quick Overview

The jrottenberg/ffmpeg repository is a Docker image project that provides a pre-built FFmpeg installation. It offers a convenient way to use FFmpeg in containerized environments, making it easier to deploy and use FFmpeg across different platforms without worrying about dependencies or system-specific installations.

Pros

  • Easy deployment of FFmpeg in containerized environments
  • Regularly updated with the latest FFmpeg versions
  • Supports multiple architectures (x86_64, arm64, armhf)
  • Includes various build options and additional libraries for extended functionality

Cons

  • May have a larger image size compared to a minimal FFmpeg installation
  • Requires Docker to be installed and running on the host system
  • Limited customization options compared to building FFmpeg from source
  • Potential security concerns when using pre-built images in sensitive environments

Getting Started

To use the jrottenberg/ffmpeg Docker image, follow these steps:

  1. Ensure Docker is installed on your system.
  2. Pull the latest image:
    docker pull jrottenberg/ffmpeg
    
  3. Run FFmpeg commands using the Docker container:
    docker run -v $(pwd):/tmp/workdir jrottenberg/ffmpeg -i /tmp/workdir/input.mp4 /tmp/workdir/output.mp4
    

This example mounts the current directory to /tmp/workdir in the container and converts input.mp4 to output.mp4 using FFmpeg.

Competitor Comparisons

44,846

Mirror of https://git.ffmpeg.org/ffmpeg.git

Pros of FFmpeg

  • Official source repository with the most up-to-date codebase
  • Comprehensive documentation and extensive community support
  • Wider range of features and customization options

Cons of FFmpeg

  • Requires manual compilation and installation
  • More complex setup process for beginners
  • Larger repository size due to full source code and development history

Code Comparison

FFmpeg:

int main(int argc, char **argv) {
    AVFormatContext *fmt_ctx = NULL;
    AVCodecContext *dec_ctx = NULL;
    AVStream *video_stream = NULL;
    const char *src_filename = NULL;

jrottenberg/ffmpeg:

FROM        alpine:3.17 as base

RUN     apk  add --no-cache --update libgcc libstdc++ ca-certificates libcrypto1.1 libssl1.1 libgomp expat

FROM        base AS build

The FFmpeg repository contains the actual source code of the FFmpeg project, while jrottenberg/ffmpeg is a Docker image that packages FFmpeg for easy deployment. The code snippets show this difference, with FFmpeg displaying C code for video processing and jrottenberg/ffmpeg showing a Dockerfile for building the container image.

jrottenberg/ffmpeg simplifies the deployment process, especially for containerized environments, but may have limitations in terms of customization and access to the latest features compared to the official FFmpeg repository.

Pros of FFmpeg-Builds

  • Offers a wider range of build options and configurations
  • Provides more up-to-date builds with the latest FFmpeg features
  • Includes builds for multiple platforms and architectures

Cons of FFmpeg-Builds

  • Less focus on Docker integration compared to ffmpeg
  • May have a steeper learning curve for users new to FFmpeg
  • Potentially larger file sizes due to more comprehensive builds

Code Comparison

FFmpeg-Builds:

./build.sh --target=win64-gpl --enable-gpl --enable-version3 --enable-sdl2

ffmpeg:

FROM jrottenberg/ffmpeg:4.3-alpine
RUN ffmpeg -version

The FFmpeg-Builds example shows a build script with custom options, while the ffmpeg example demonstrates a simple Docker usage.

The FFmpeg build script provides an easy way to build a static FFmpeg on OSX and Linux with non-free codecs included.

Pros of ffmpeg-build-script

  • Offers more customization options for building FFmpeg
  • Supports building on a wider range of operating systems
  • Provides a more up-to-date FFmpeg build with the latest features

Cons of ffmpeg-build-script

  • Requires more manual setup and configuration
  • May have longer build times due to compiling from source
  • Less suitable for quick deployments or containerized environments

Code Comparison

ffmpeg-build-script:

./build-ffmpeg --build

ffmpeg:

FROM jrottenberg/ffmpeg:4.4-ubuntu

Summary

ffmpeg-build-script is better suited for users who need custom FFmpeg builds with specific features or optimizations. It offers more flexibility but requires more setup time and technical knowledge.

ffmpeg is ideal for users who need a pre-built FFmpeg solution, especially in containerized environments. It's quicker to deploy but offers less customization.

The choice between the two depends on the specific use case, with ffmpeg-build-script favoring customization and ffmpeg prioritizing ease of use and quick deployment.

Port of FFmpeg with Emscripten

Pros of ffmpeg.js

  • Runs in the browser, enabling client-side video processing without server-side dependencies
  • Lightweight and portable, suitable for web applications and environments where installing FFmpeg is not feasible
  • Provides a JavaScript API for easier integration with web applications

Cons of ffmpeg.js

  • Limited functionality compared to the full FFmpeg suite
  • May have performance limitations for complex video processing tasks in the browser
  • Requires additional setup and configuration for use in web projects

Code Comparison

ffmpeg.js:

const ffmpeg = require('ffmpeg.js');
const result = ffmpeg({
  MEMFS: [{ name: "test.webm", data: testData }],
  arguments: ["-i", "test.webm", "-c:v", "libx264", "out.mp4"],
});

ffmpeg:

ffmpeg -i input.webm -c:v libx264 output.mp4

Summary

ffmpeg.js is a JavaScript port of FFmpeg that runs in the browser, offering client-side video processing capabilities. It's lightweight and portable but has limited functionality compared to the full FFmpeg suite. The ffmpeg repository provides the complete FFmpeg toolset, offering more extensive features and better performance for complex tasks, but requires server-side installation and execution.

3,679

The fastest and safest AV1 encoder.

Pros of rav1e

  • Specialized AV1 encoder, potentially offering better AV1-specific optimizations
  • Written in Rust, providing memory safety and performance benefits
  • More focused development on AV1 encoding, potentially leading to faster updates for this specific codec

Cons of rav1e

  • Limited to AV1 encoding, lacking the versatility of FFmpeg's multi-codec support
  • Smaller community and ecosystem compared to FFmpeg's extensive user base and plugins
  • May require additional tools for full video processing workflows, unlike FFmpeg's all-in-one solution

Code Comparison

rav1e (Rust):

use rav1e::prelude::*;

let cfg = Config::default();
let mut ctx: Context<u8> = cfg.new_context().unwrap();
let frame = ctx.new_frame();
ctx.send_frame(frame).unwrap();

FFmpeg (C):

AVCodecContext *c = avcodec_alloc_context3(codec);
AVFrame *frame = av_frame_alloc();
avcodec_open2(c, codec, NULL);
av_init_packet(&pkt);
avcodec_send_frame(c, frame);

Both repositories serve different purposes within the video encoding ecosystem. rav1e focuses exclusively on AV1 encoding, leveraging Rust's benefits, while FFmpeg offers a comprehensive suite of audio and video processing tools with support for multiple codecs. The choice between them depends on specific project requirements and the desired level of specialization versus versatility.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

FFmpeg Docker image

Docker Stars Docker pulls Docker Automated build Github Container Registry Images gitlab pipeline status Azure Build Status

This project prepares a minimalist Docker image with FFmpeg. It compiles FFmpeg from sources following instructions from the Compilation Guide.

You can install the latest build of this image by running docker pull jrottenberg/ffmpeg:${VERSION}-${VARIANT} or docker pull ghcr.io/jrottenberg/ffmpeg:${VERSION}-${VARIANT}.

This image can be used as a base for an encoding farm.

Builds

There are different builds available:

  • alpine based images ffmpeg:<version>-alpine or ffmpeg:<version>-alpine313 (old versions with ffmpeg:<version>-alpine312 , ffmpeg:<version>-alpine311)
    • alpine based scratch images ffmpeg:<version>-scratch or ffmpeg:<version>-scratch313 (old versions with ffmpeg:<version>-scratch312 , ffmpeg:<version>-scratch311)
  • ubuntu based images ffmpeg:<version>-ubuntu or ffmpeg:<version>-ubuntu2004 (old versions with ffmpeg:<version>-ubuntu1804 , ffmpeg:<version>-ubuntu1604)
    • ubuntu based nvidia images ffmpeg:<version>-nvidia or ffmpeg:<version>-nvidia2004 (old versions with ffmpeg:<version>-nvidia1804, ffmpeg:<version>-nvidia1604)
    • ubuntu based vaapi images ffmpeg:<version>-vaapi1804 or ffmpeg:<version>-vaapi2004 (old versions with ffmpeg:<version>-vaapi1804, ffmpeg:<version>-nvidia1604)

<version> can be one of the following:

  • 3.2
  • 3.3
  • 3.4
  • 4.0
  • 4.1
  • 4.2
  • 4.3
  • 4.4

Generate list of recent images

You can use the following command to generate a list of current images:

$ curl --silent https://hub.docker.com/v2/repositories/jrottenberg/ffmpeg/tags/?page_size=500 | jq -cr ".results|sort_by(.name)|reverse[]|.sz=(.full_size/1048576|floor|tostring+\"mb\")|[.name,( (20-(.name|length))*\" \" ),.sz,( (8-(.sz|length))*\" \"),.last_updated[:10]]|@text|gsub(\"[,\\\"\\\]\\\[]\";null)"

If you want to compare the one you have locally, use the following command:

$ docker images | grep ffmpeg | sort | awk '{print $1 ":" $2 "\t" $7 $8}'

Please use Github issues to report any bug or missing feature.

Test

ffmpeg version N-98740-ga72d529 Copyright (c) 2000-2020 the FFmpeg developers
  built with gcc 7 (Ubuntu 7.5.0-3ubuntu1~18.04)
  configuration: --disable-debug --disable-doc --disable-ffplay --enable-shared --enable-avresample --enable-libopencore-amrnb --enable-libopencore-amrwb --enable-gpl --enable-libass --enable-fontconfig --enable-libfreetype --enable-libvidstab --enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libvpx --enable-libwebp --enable-libxcb --enable-libx265 --enable-libxvid --enable-libx264 --enable-nonfree --enable-openssl --enable-libfdk_aac --enable-postproc --enable-small --enable-version3 --enable-libbluray --enable-libzmq --extra-libs=-ldl --prefix=/opt/ffmpeg --enable-libopenjpeg --enable-libkvazaar --enable-libaom --extra-libs=-lpthread --enable-libsrt --enable-libaribb24 --enable-vaapi --extra-cflags=-I/opt/ffmpeg/include --extra-ldflags=-L/opt/ffmpeg/lib
  libavutil      56. 58.100 / 56. 58.100
  libavcodec     58.100.100 / 58.100.100
  libavformat    58. 51.100 / 58. 51.100
  libavdevice    58. 11.101 / 58. 11.101
  libavfilter     7. 87.100 /  7. 87.100
  libavresample   4.  0.  0 /  4.  0.  0
  libswscale      5.  8.100 /  5.  8.100
  libswresample   3.  8.100 /  3.  8.100
  libpostproc    55.  8.100 / 55.  8.100

  configuration:
    --disable-debug
    --disable-doc
    --disable-ffplay
    --enable-shared
    --enable-avresample
    --enable-libopencore-amrnb
    --enable-libopencore-amrwb
    --enable-gpl
    --enable-libass
    --enable-fontconfig
    --enable-libfreetype
    --enable-libvidstab
    --enable-libmp3lame
    --enable-libopus
    --enable-libtheora
    --enable-libvorbis
    --enable-libvpx
    --enable-libwebp
    --enable-libxcb
    --enable-libx265
    --enable-libxvid
    --enable-libx264
    --enable-nonfree
    --enable-openssl
    --enable-libfdk_aac
    --enable-postproc
    --enable-small
    --enable-version3
    --enable-libbluray
    --enable-libzmq
    --extra-libs=-ldl
    --prefix=/opt/ffmpeg
    --enable-libopenjpeg
    --enable-libkvazaar
    --enable-libaom
    --extra-libs=-lpthread
    --enable-libsrt
    --enable-libaribb24
    --enable-vaapi
    --extra-cflags=-I/opt/ffmpeg/include
    --extra-ldflags=-L/opt/ffmpeg/lib

Capture output from the container to the host running the command

 docker run jrottenberg/ffmpeg:4.4-alpine \
            -i http://url/to/media.mp4 \
            -stats \
            $ffmpeg_options  - > out.mp4

Examples

Extract 5s @00:49:42 into a GIF

 docker run jrottenberg/ffmpeg:4.4-alpine -stats  \
        -i http://archive.org/download/thethreeagesbusterkeaton/Buster.Keaton.The.Three.Ages.ogv \
        -loop 0  \
        -final_delay 500 -c:v gif -f gif -ss 00:49:42 -t 5 - > trow_ball.gif

Convert 10bits MKV into a 10Bits MP4

 docker run -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg:4.4-scratch \
        -stats \
        -i http://www.jell.yfish.us/media/jellyfish-20-mbps-hd-hevc-10bit.mkv \
        -c:v libx265 -pix_fmt yuv420p10 \
        -t 5 -f mp4 test.mp4

The image has been compiled with X265 Multilib. Use the pixel format switch to change the number of bits per pixel by suffixing it with 10 for 10bits or 12 for 12bits.

Convert a local GIF into a mp4

Let's assume original.gif is located in the current directory :

 docker run -v $(pwd):$(pwd) -w $(pwd)\
        jrottenberg/ffmpeg:4.4-scratch -stats \
        -i original.gif \
        original-converted.mp4

Use ZeroMQ to toggle filter value on-fly

Let's start some process continuously writing some radio music, and listen it:

docker run --rm -d -v $(pwd):$(pwd) -w $(pwd) -p 11235:11235 \
        --name radio-writer jrottenberg/ffmpeg:4.4-alpine \
        -i http://radio.casse-tete.solutions/salut-radio-64.mp3 \
        -filter_complex '[0:a]volume@vol=1,azmq=bind_address=tcp\\\://0.0.0.0\\\:11235[out]' \
        -map '[out]' ./salut-radio.mp3

docker run -it -v $(pwd):$(pwd) -w $(pwd) --entrypoint=ffprobe jrottenberg/ffmpeg:4.4-alpine -v quiet  -show_streams salut-radio.mp3

Now, just toggle its volume on-fly, and hear how it changes:

docker run --rm --network=host --entrypoint sh jrottenberg/ffmpeg:4.4-ubuntu -c \
        'echo "volume@vol volume 2" | zmqsend -b tcp://127.0.0.1:11235'

Send a stream over SRT

Let's send video.mp4 to srt-listener on port 9000 over SRT protocol.

docker run -v $(pwd):$(pwd) jrottenberg/ffmpeg:4.4-centos \
       -re -i $(pwd)/video.mp4 -acodec copy -vcodec copy -f mpegts srt://srt-listener:9000?pkt_size=1316

Use hardware acceleration enabled build

Thanks to qmfrederik for the vaapi ubuntu based variant

jrottenberg/ffmpeg:vaapi or jrottenberg/ffmpeg:${VERSION}-vaapi

  • Run the container with the device attached /dev/dri from your host into the container :

docker run --device /dev/dri:/dev/dri -v $(pwd):$(pwd) -w $(pwd) jrottenberg/ffmpeg:4.4-vaapi [...]

  • Have the Intel drivers up and running on your host. You can run vainfo (part of vainfo package on Ubuntu) to determine whether your graphics card has been recognized correctly.
  • Run ffmpeg with the correct parameters, this is the same as when running ffmpeg natively.

Use nvidia hardware acceleration enabled build

Thanks to ShaulMyplay for the nvidia based variant

Supports nvenc only on all ffmpeg versions, and hardware decoding and scaling on ffmpeg >= 4.0

Hardware encoding only example:

docker run --runtime=nvidia jrottenberg/ffmpeg:4.4-nvidia -i INPUT -c:v nvenc_h264 -preset hq OUTPUT Full hardware acceleration example: docker run --runtime=nvidia jrottenberg/ffmpeg:4.4-nvidia -hwaccel cuvid -c:v h264_cuvid -i INPUT -vf scale_npp=-1:720 -c:v h264_nvenc -preset slow OUTPUT

See what's inside the beast
docker run -it --entrypoint='bash' jrottenberg/ffmpeg:4.4-ubuntu

for i in ogg amr vorbis theora mp3lame opus vpx xvid fdk x264 x265;do echo $i; find /usr/local/ -name *$i*;done

Keep up to date

See Dockerfile-env to update a version

Contribute

See the contributing guide

Legal

Those docker images use code of <a href=http://ffmpeg.org>FFmpeg licensed under the <a href=http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html>LGPLv2.1 and their source can be downloaded on <a href=https://github.com/jrottenberg/ffmpeg>github.com/jrottenberg/ffmpeg.