This repository has been archived by the owner on Aug 29, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
start
executable file
·44 lines (40 loc) · 1.77 KB
/
start
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/sh
if [ ! -f "$1" ]; then
>&2 echo "Missing input file: '$1'"
>&2 echo "Syntax: $(basename $0) <input-file> <output-file>"
return 1
fi
if [ -z "$2" ]; then
>&2 echo "Missing argument for output file"
>&2 echo "Syntax: $(basename $0) <input-file> <output-file>"
return 1
fi
in_fullpath=$(realpath "$1")
in_dir_host=$(dirname "$in_fullpath")
in_file=$( basename "$in_fullpath")
out_fullpath=$(realpath -m "$2")
out_dir_host=$(dirname "$out_fullpath")
out_file=$( basename "$out_fullpath")
in_dir_container='/video/in'
out_dir_container='/video/out'
user="${PUID:-$(id -u)}:${PGID:-$(id -g)}"
env_args=''
[ "${VIDEO_CODEC}" ] && env_args="${env_args} -e VIDEO_CODEC=${VIDEO_CODEC}"
[ "${VIDEO_BITRATE}" ] && env_args="${env_args} -e VIDEO_BITRATE=${VIDEO_BITRATE}"
[ "${VIDEO_WIDTH}" ] && env_args="${env_args} -e VIDEO_WIDTH=${VIDEO_WIDTH}"
[ "${AUDIO_CODEC}" ] && env_args="${env_args} -e AUDIO_CODEC=${AUDIO_CODEC}"
[ "${AUDIO_BITRATE}" ] && env_args="${env_args} -e AUDIO_BITRATE=${AUDIO_BITRATE}"
[ "${AUDIO_CHANNELS}" ] && env_args="${env_args} -e AUDIO_CHANNELS=${AUDIO_CHANNELS}"
[ "${AUDIO_LANGUAGES}" ] && env_args="${env_args} -e AUDIO_LANGUAGES=${AUDIO_LANGUAGES}"
[ "${VAAPI_DEVICE}" ] && env_args="${env_args} -e VAAPI_DEVICE=${VAAPI_DEVICE}"
docker-compose \
--file $(dirname "$0")/docker-compose.yml \
run \
--user "${user}" \
--rm \
-v "${in_dir_host}:${in_dir_container}:ro" \
-v "${out_dir_host}:${out_dir_container}" \
$env_args \
vaapi-video-converter \
"${in_dir_container}/${in_file}" \
"${out_dir_container}/${out_file}"