Skip to content

Commit

Permalink
add Dockerfile
Browse files Browse the repository at this point in the history
  • Loading branch information
slhck committed Apr 12, 2019
1 parent a021d8c commit df6d42c
Show file tree
Hide file tree
Showing 4 changed files with 99 additions and 2 deletions.
32 changes: 32 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
FROM ubuntu:bionic
LABEL maintainer="Werner Robitza <werner.robitza@gmail.com>"
LABEL name="ffmpeg_quality_metrics"
ARG DEBIAN_FRONTEND=noninteractive

RUN apt-get update \
&& apt-get install -y --no-install-recommends ca-certificates curl file g++ git locales make uuid-runtime python3-pip \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/* \
&& localedef -i en_US -f UTF-8 en_US.UTF-8 \
&& useradd -m -s /bin/bash linuxbrew \
&& echo 'linuxbrew ALL=(ALL) NOPASSWD:ALL' >>/etc/sudoers

USER linuxbrew
WORKDIR /home/linuxbrew
ENV PATH=/home/linuxbrew/.linuxbrew/bin:/home/linuxbrew/.linuxbrew/sbin:$PATH \
SHELL=/bin/bash

RUN git clone https://github.com/Linuxbrew/brew.git /home/linuxbrew/.linuxbrew/Homebrew \
&& mkdir /home/linuxbrew/.linuxbrew/bin \
&& ln -s ../Homebrew/bin/brew /home/linuxbrew/.linuxbrew/bin/ \
&& brew config

RUN brew tap varenc/ffmpeg \
&& brew install varenc/ffmpeg/ffmpeg --with-libvmaf

COPY requirements.txt .
RUN pip3 install -r requirements.txt

COPY ffmpeg_quality_metrics.py .

ENTRYPOINT ["python3", "./ffmpeg_quality_metrics.py"]
31 changes: 29 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,26 @@ Currently supports PSNR and SSIM. VMAF to follow.

Author: Werner Robitza <werner.robitza@gmail.com>

Contents:

- [Requirements](#requirements)
- [Installation](#installation)
- [Usage](#usage)
- [Running with Docker](#running-with-docker)
- [Output](#output)
- [License](#license)

------

## Requirements

- Python 3.6
- FFmpeg:
- download a static build from [their website](http://ffmpeg.org/download.html))
- put the `ffmpeg` executable in your `$PATH`
- `pip3 install pandas`
- `pip3 install -r requirements.txt`

Optionally, you may install FFmpeg with `libvmaf` support to run VMAF score calculation.

## Installation

Expand All @@ -22,6 +35,20 @@ Clone this repo and run `ffmpeg_quality_metrics.py`.

See `ffmpeg_quality_metrics.py -h`.

## Running with Docker

If you don't want to deal with dependencies, build the image with Docker:

```
docker build -t ffmpeg_quality_metrics .
```

This installs `ffmpeg` with all dependencies. You can then run the container, which basically calls the Python script. To help you with mounting the volumes (since your videos are not stored in the container), you can run a helper script:

```
./docker_run.sh
```

## Output

JSON or CSV, including individual fields for Y, U, V, and averages, as well as frame numbers.
Expand Down Expand Up @@ -102,7 +129,7 @@ n,mse_avg,mse_u,mse_v,mse_y,psnr_avg,psnr_u,psnr_v,psnr_y,ssim_avg,ssim_u,ssim_v
3,527.87,245.13,456.35,882.13,20.91,24.24,21.54,18.68,0.947,0.96,0.947,0.936
```

# License
## License

ffmpeg_quality_metrics, Copyright (c) 2019 Werner Robitza

Expand Down
37 changes: 37 additions & 0 deletions docker_run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#!/usr/bin/env bash
#
# Helper script to run Docker container

usage() {
echo "Usage: $0 <dist> <ref> [OPTIONS]"
echo
echo " <dist> -- distorted video"
echo " <ref> -- reference video"
echo " [OPTIONS] -- further options passed to ffmpeg_quality_metrics.py"
exit 1
}

if [ $# -lt 2 ]; then
usage
fi

distFile="$1"
refFile="$2"

distFileBasename="$(basename $1)"
refFileBasename="$(basename $2)"

distDir="$(realpath "$(dirname "$1")")"
refDir="$(realpath "$(dirname "$2")")"

shift; shift

docker run \
--rm \
-v "$distDir":"/tmp/dist" \
-v "$refDir":"/tmp/ref" \
-t ffmpeg_quality_metrics \
./ffmpeg_quality_metrics.py \
"/tmp/dist/$distFileBasename" \
"/tmp/ref/$refFileBasename" \
"$@"
1 change: 1 addition & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pandas

0 comments on commit df6d42c

Please sign in to comment.