Sign inSign up

gidat/ffmpeg-srt

By gidat

•Updated almost 7 years ago

FFMpeg with SRT protocol enabled

Image
1

300

gidat/ffmpeg-srt repository overview

⁠FFMpeg Docker with SRT protocol support

⁠Introduction

This docker is compiled with x64 architecture, using i5 microprocessor.

⁠Get started (udp multicast streaming)

Now we show a scenary with:

  • 1 looped video source (h264)
  • 1 video player.
  • The video is streamed via multicast (udp).

Note: Is very important that que required port (ie. 9999/udp) will be open

First, download docker container: docker pull gidat/ffmpeg-srt:latest

Suppose that you have a video file called test.mp4. Then, the command to launch this dockerized ffmpeg (in infinite-loop mode) could be: docker run -it --net host -v $PWD:/root --rm gidat/ffmpeg-srt ffmpeg -re -y -fflags +genpts -stream_loop -1 -i Test.mp4 -c:v libx264 -preset veryfast -tune film -c:a libfdk_aac -b:a 96k -f mpegts udp://239.0.0.1:9999?pkt_size=1316

Now, you need player. You could use a streaming compatible player on host PC. For example:

  1. With FFMpeg installed on host PC (using ffplay): ffplay udp://@239.0.0.1:9999?pkt_size=1316

  2. Same situation, but with vlc on host PC: cvlc udp://@239.0.0.1:9999?pkt_size=1316

⁠Streaming over SRT (h264)

  1. Suppose that you have a video file called test.mp4. Then, the command to launch this dockerized ffmpeg (in infinite-loop mode) could be: docker run -it -p 9999:9999 --name video-src -v $PWD:/root --rm gidat/ffmpeg-srt ffmpeg -re -y -fflags +genpts -stream_loop -1 -i Test.mp4 -c:v libx264 -preset veryfast -tune film -c:a libfdk_aac -b:a 96k -f mpegts udp://239.0.0.1:9999?pkt_size=1316

  2. docker run -it -p 9999:9999 -p 8888:8888 -v $PWD:/root --rm gidat/ffmpeg-srt ffmpeg -fflags +genpts -listen 1 -re -i udp://239.0.0.1:9999?pkt_size=1316 -acodec copy -vcodec copy -strict -2 -y -f mpegts srt://0.0.0.0:8888?pkt_size=1316&mode=listener

  3. docker run -it -p 9999:9999 -p 8888:8888 -v $PWD:/root --rm gidat/ffmpeg-srt ffmpeg -re -i srt://0.0.0.0:8888?pkt_size=1316&mode=listener -vcodec copy -acodec copy -strict -2 -y -f mpegts udp://239.0.0.2:1234?pkt_size=1316

  4. ffplay udp://@239.0.0.2:1234?pkt_size=1316

⁠Streaming over SRT (h265)

TODO :-)

⁠Dockerfile

# Generate a docker for full featured ffmpeg with srt support
# by GIDAT -UNRC
# VERSION               1.0.0
# based on: Eyevinn/toolbox

FROM debian:buster-slim
LABEL MAINTAINER="[email protected]"
ENV HOME /root
ENV DEBIAN_FRONTEND noninteractive

# Update

RUN apt update && apt upgrade -y && apt dist-upgrade -y

# Dependecies

RUN apt install --no-install-recommends -y python3-pip python3-setuptools python3-wheel && apt install --no-install-recommends -y autoconf automake build-essential pkg-config libtool wget yasm libx264-dev git cmake \
    ninja-build nasm libvpx-dev libssl-dev libx265-dev libnuma-dev libfreetype6-dev && \
    DEBIAN_FRONTEND=noninteractive apt-get install -y tclsh && \
    pip3 install meson && rm -rf /var/lib/apt/lists/*

# SRC folder
RUN mkdir -p /root/source/ffmpeg && cd /root/source/ffmpeg

# FDK-AAC
RUN wget -O fdk-aac.tar.gz https://github.com/mstorsjo/fdk-aac/tarball/master && \
  tar xzvf fdk-aac.tar.gz && \
  cd mstorsjo-fdk-aac* && \
  autoreconf -fiv && \
  ./configure --disable-shared && \
  make -j4 && \
  make install && \
  make distclean

# AOM
RUN mkdir -p /root/source/ffmpeg/libaom && \
  cd /root/source/ffmpeg/libaom && \
  git clone https://aomedia.googlesource.com/aom && \
  cmake ./aom && \
  make -j4 && \
  make install

# Dav1d (AV1 decoder)

RUN cd /root/source/ffmpeg && \
  git clone https://code.videolan.org/videolan/dav1d.git && \
  cd dav1d && \
  meson build --buildtype release && \
  ninja -C build && \
  ninja -C build install && \
  ldconfig

# SRT Haivision
RUN cd /root/source/ffmpeg && \
  git clone https://github.com/Haivision/srt.git && \
  cd srt && \
  ./configure && \
  make -j4 && make install && \
  ldconfig

# Final build (with hope :-) )

RUN cd /root/source/ffmpeg && \
  wget http://ffmpeg.org/releases/ffmpeg-snapshot.tar.bz2 && \
  tar xjvf ffmpeg-snapshot.tar.bz2 && \
  cd ffmpeg && \
  ./configure \
    --pkg-config-flags="--static" \
    --enable-gpl \
    --enable-libfdk-aac \
    --enable-libx264 \
    --enable-libaom \
    --enable-libdav1d \
    --enable-libvpx \
    --enable-libsrt \
    --enable-libx265 \
    --enable-libfreetype \
    --enable-version3 \
    --enable-nonfree && \
  make -j4 && \
  make install && \
  make distclean && \
  hash -r

# Clean 
RUN pip3 uninstall -y meson && \
    DEBIAN_FRONTEND=noninteractive && apt-get purge -y --allow-remove-essential \
    ca-certificates autoconf automake build-essential pkg-config libtool wget yasm \
    autoconf automake build-essential pkg-config libtool wget yasm git cmake \
    ninja-build nasm  && apt-get autoremove -y && \
    apt clean -y && rm -rf /var/lib/apt/lists/* && rm -r /root/source/

WORKDIR /root

⁠Credits / Bibliography

Based/Inspired on several others works:

Tag summary

Content type

Image

Digest

Size

608 MB

Last updated

almost 7 years ago

docker pull gidat/ffmpeg-srt