aboutsummaryrefslogtreecommitdiff
path: root/tests/normalize-notify/fake-ffmpeg
blob: cdfcb6f5dfe9bae519170cf10a9b517ddb51fe30 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/bin/bash
# Fake ffmpeg for the normalize-notify-sounds tests. Two modes:
#   measure  (args include the `volumedetect` filter): print a mean_volume line
#            to stderr, driven by FAKE_MEAN (default -20.0).
#   encode   (otherwise): write to the output file (the last argument), driven
#            by FAKE_FFMPEG_EMPTY (1 -> zero-byte output) and FAKE_FFMPEG_FAIL
#            (1 -> exit non-zero without writing).
set -uo pipefail

for a in "$@"; do
    if [ "$a" = "volumedetect" ]; then
        echo "mean_volume: ${FAKE_MEAN:--20.0} dB" >&2
        exit 0
    fi
done

out="${*: -1}"
if [ "${FAKE_FFMPEG_FAIL:-0}" = 1 ]; then
    exit 1
fi
if [ "${FAKE_FFMPEG_EMPTY:-0}" = 1 ]; then
    : > "$out"
else
    echo ENCODED > "$out"
fi