Skip to content

Instantly share code, notes, and snippets.

@guss77
Created July 4, 2020 18:51
Show Gist options
  • Save guss77/b71f6dddfda035116a97da4c47d92b8f to your computer and use it in GitHub Desktop.
Save guss77/b71f6dddfda035116a97da4c47d92b8f to your computer and use it in GitHub Desktop.
Build alternative FFMPEG for Jellyfin
FROM debian:10
# install Debian dependencies
RUN apt-get update && \
apt-get install -qy subversion git gcc g++ cmake nasm pkg-config \
libgmp-dev gnutls-dev libass-dev libfreetype6-dev libbluray-dev libfribidi-dev libdrm-dev libmp3lame-dev libopus-dev libtheora-dev libvorbis-dev libwebp-dev libx264-dev libx265-dev libzvbi-dev libva-dev && \
rm -rf /var/lib/apt
# Install NV codec support
WORKDIR /ffmpeg
RUN git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git
WORKDIR /ffmpeg/nv-codec-headers
RUN make install
# Download and setup AMD AMF headers
# https://www.ffmpeg.org/general.html#AMD-AMF_002fVCE
WORKDIR /ffmpeg
RUN svn checkout https://github.com/GPUOpen-LibrariesAndSDKs/AMF/trunk/amf/public/include AMF
WORKDIR /ffmpeg/AMF
RUN mkdir -p /usr/local/include/AMF
RUN mv * /usr/local/include/AMF
### Additional FFMPEG non-Jellybin stuff
# Download and build SVT codecs
WORKDIR /ffmpeg
RUN git clone --depth=1 https://github.com/OpenVisualCloud/SVT-HEVC
WORKDIR /ffmpeg/SVT-HEVC/Build/linux
RUN bash -x ./build.sh static release
WORKDIR /ffmpeg/SVT-HEVC/Build/linux/Release
RUN make install
WORKDIR /ffmpeg
RUN git clone --depth=1 https://github.com/OpenVisualCloud/SVT-AV1
WORKDIR /ffmpeg/SVT-AV1/Build
RUN cmake .. -G"Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=off
RUN make -j $(nproc)
RUN make install
# Dowbload and build FFMPEG
WORKDIR /ffmpeg
RUN git clone --depth=1 -b release/4.2 https://github.com/FFmpeg/FFmpeg ffmpeg
WORKDIR /ffmpeg/ffmpeg
RUN git config --global user.email "[email protected]" # 'git apply' requite the git identity to be set for some reason
RUN git am ../SVT-HEVC/ffmpeg_plugin/0001*.patch
RUN git apply ../SVT-AV1/ffmpeg_plugin/0001-Add-ability-for-ffmpeg-to-run-svt-av1.patch
#RUN export LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/usr/local/lib; export PKG_CONFIG_PATH=${PKG_CONFIG_PATH}:/usr/local/lib/pkgconfig;
RUN ./configure \
--prefix=/usr/lib/jellyfin-ffmpeg --target-os=linux --disable-doc --disable-ffplay --disable-shared --disable-libxcb --disable-vdpau --disable-sdl2 --disable-xlib \
--enable-gpl --enable-version3 --enable-static --enable-libfontconfig --enable-fontconfig --enable-gmp --enable-gnutls --enable-libass --enable-libbluray --enable-libdrm --enable-libfreetype --enable-libfribidi \
--enable-libmp3lame --enable-libopus --enable-libtheora --enable-libvorbis --enable-libwebp --enable-libx264 --enable-libx265 --enable-libzvbi --arch=amd64 --enable-amf --enable-nvenc --enable-nvdec --enable-vaapi \
--enable-libsvthevc --enable-libsvtav1 && \
make -j $(nproc)
VOLUME /output
CMD cp /ffmpeg/ffmpeg/ffmpeg /ffmpeg/ffmpeg/ffprobe /output
@guss77
Copy link
Author

guss77 commented Jul 4, 2020

The above example is basically a pure rebuild of the Jellyfin FMFPEG build in docker, with the addition of the SVT HEVC and AV1 codecs (you can add others, just make sure any dependencies are statically linked).

To build, use the above file like this:

docker build -f build-ffmpeg.Dockerfile -t ffmpeg-build . && docker run -ti --rm -v ${PWD}:/output ffmpeg-build

This will create an ffmpeg and ffprobe files in the current directory. You can then drop them over the Jellyfin FFMPEG files. For example, when using the official Jellyfin containers, add -v /your/ffmpeg:/usr/lib/jellyfin-ffmpeg/ffmpeg -v /your/ffprobe:/usr/lib/jellyfin-ffmpeg/ffprobe.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment