From 2feb4940a9e2c09a51a4bab154cabbd6e7020d65 Mon Sep 17 00:00:00 2001 From: "J. Oliva" Date: Thu, 18 Oct 2018 23:07:05 +0200 Subject: [PATCH 1/2] Add docker support --- .dockerignore | 4 +++ Dockerfile | 17 ++++++++++++ buildEncoderAndServerForUbuntu.sh | 41 ++++------------------------ installDeps.sh | 44 +++++++++++++++++++++++++++++++ launchEncoderTestPattern.sh | 2 +- 5 files changed, 71 insertions(+), 37 deletions(-) create mode 100644 .dockerignore create mode 100644 Dockerfile create mode 100644 installDeps.sh diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..6d437f1 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,4 @@ +.git +.gitignore +LICENSE +README.md diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..d45923a --- /dev/null +++ b/Dockerfile @@ -0,0 +1,17 @@ +FROM ubuntu:16.04 + +WORKDIR /low-latency-preview + +RUN apt-get update && apt-get install -y software-properties-common python-software-properties +COPY installDeps.sh . +RUN chmod +x installDeps.sh +RUN ./installDeps.sh + +COPY . . +RUN chmod +x *.sh +RUN ./buildEncoderAndServerForUbuntu.sh --no-deps + +EXPOSE 8080 + +ENTRYPOINT ["/bin/bash"] + diff --git a/buildEncoderAndServerForUbuntu.sh b/buildEncoderAndServerForUbuntu.sh index 832a998..5f10608 100755 --- a/buildEncoderAndServerForUbuntu.sh +++ b/buildEncoderAndServerForUbuntu.sh @@ -1,16 +1,9 @@ #!/bin/bash -# instlal go repo - -sudo add-apt-repository -y ppa:longsleep/golang-backports - -# update the OS - -sudo apt-get -y update - -sudo apt-get -y upgrade - -sudo apt-get install -y yasm libx264-dev libfreetype6-dev golang-go libass-dev pkg-config texinfo build-essential automake autoconf libssl-dev +# By default install dependencies +if [ $1 != "--no-deps" ]; then + ./installDeps.sh +fi export GOPATH=$HOME/go export PATH=$PATH:$GOROOT/bin:$GOPATH/bin @@ -18,28 +11,4 @@ go get -d -v . go build -mkdir www logs - -# Download and compile FFmpeg - -rm -r -f ffmpeg/ - -git clone http://github.com/FFmpeg/ffmpeg.git -b master - -cd ffmpeg - -# Configure FFmpeg build - -./configure \ - --enable-gpl \ - --enable-libass \ - --enable-libx264 \ - --enable-nonfree \ - --enable-openssl \ - --enable-libfreetype - -# Build ffmpeg - -make - -cd .. +mkdir -p www logs diff --git a/installDeps.sh b/installDeps.sh new file mode 100644 index 0000000..ad6f156 --- /dev/null +++ b/installDeps.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +# Use sudo only if not using root + +sudo () +{ + [[ $EUID = 0 ]] || set -- command sudo "$@" + "$@" +} + +# install go repo + +sudo add-apt-repository -y ppa:longsleep/golang-backports + +# update the OS + +sudo apt-get -y update + +sudo apt-get -y upgrade +sudo apt-get install -y git yasm libx264-dev libfreetype6-dev golang-go libass-dev pkg-config texinfo build-essential automake autoconf libssl-dev software-properties-common python-software-properties git + +# Download and compile FFmpeg + +rm -r -f ffmpeg/ + +git clone http://github.com/FFmpeg/ffmpeg.git -b master + +cd ffmpeg + +# Configure FFmpeg build + +./configure \ + --enable-gpl \ + --enable-libass \ + --enable-libx264 \ + --enable-nonfree \ + --enable-openssl \ + --enable-libfreetype + +# Build ffmpeg + +make + +cd .. \ No newline at end of file diff --git a/launchEncoderTestPattern.sh b/launchEncoderTestPattern.sh index b9559a9..9041171 100755 --- a/launchEncoderTestPattern.sh +++ b/launchEncoderTestPattern.sh @@ -33,4 +33,4 @@ ffmpeg/ffmpeg \ -remove_at_exit 1 \ -adaptation_sets "id=0,streams=v id=1,streams=a" \ -f dash \ - http://${1}:8080/ldash/${2}/manifest.mpd >/dev/null 2>logs/encode.log & + http://${1}:8080/ldash/${2}/manifest.mpd >/dev/null 2>logs/encode.log From 51883de46fdb5b7695b799b79832e1afbcbf27a3 Mon Sep 17 00:00:00 2001 From: "J. Oliva" Date: Thu, 18 Oct 2018 23:33:23 +0200 Subject: [PATCH 2/2] Update documentation --- README.md | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d27c2a4..df89e67 100644 --- a/README.md +++ b/README.md @@ -26,7 +26,7 @@ Run... git clone https://github.com/colleenkhenry/low-latency-preview.git -Run... +Run... cd low-latency-preview @@ -46,7 +46,7 @@ To run the encoder ./launchEncoderTestPattern.sh *insert destination hostname of server* *insert a stream name* -Example: +Example: ./launchEncoderTestPattern.sh localhost 1234 @@ -63,6 +63,27 @@ To kill the streams You can modify the FFmpeg encoding settings to taste for resolution, inputs, etc. +### How to run using docker (OSX/Windows) +#### Build docker image +```docker build -t low-latency-preview .``` + +#### Run the server +```docker run -d -p 8080:8080 low-latency-preview launchServer.sh``` + +#### Run the encoder +In OSX: + +```docker run -d low-latency-preview launchEncoderTestPattern.sh docker.for.mac.localhost 1234``` + +In Linux: + +```docker run -d low-latency-preview launchEncoderTestPattern.sh localhost 1234``` + +Note for mac: There is a known bug in docker for mac that causes docker containers time to be out of sync with osx host (https://github.com/docker/for-mac/issues/1260). That's specially annoying when working with mpeg-dash streams, that requires a good time synchronization so all timing calculations are correct. To fix this issue you have to run the following command before launching any of the previous containers (server/encoder): + +```docker run --rm --privileged alpine hwclock -s``` + + We are using the dash.js player. Feel free to visit http://reference.dashif.org/dash.js/nightly/samples/dash-if-reference-player/index.html for their nightly referencep player or their github at https://github.com/Dash-Industry-Forum/dash.js/wiki. Help wanted :)