forked from AndrewBreyen/Jellyfin-TV-Post-Process
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpost-process-2.sh
More file actions
47 lines (35 loc) · 1.06 KB
/
post-process-2.sh
File metadata and controls
47 lines (35 loc) · 1.06 KB
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
45
46
47
#!/bin/bash
set -o errexit
set -o pipefail
set -o nounset
# set -o xtrace
PWD="$(pwd)"
die () {
echo >&2 "$@"
cd "${PWD}"
exit 1
}
# Colors
GREEN='\033[0;32m'
NC='\033[0m' # No Color
__path="${1:-}"
# verify a path was provided
[ -n "$__path" ] || die "path is required"
# verify the path exists
[ -f "$__path" ] || die "path ($__path) is not a file"
__dir="$(dirname "${__path}")"
__file="$(basename "${__path}")"
__base="$(basename "${__path}" ".ts")"
# Try to find local version of ffmpeg, defaults to the path used in docker if not found
__ffmpeg="$(which ffmpeg || echo '/usr/local/bin/ffmpeg')"
# Change to the directory containing the recording
cd "${__dir}"
# Transcode to mp4
printf "[post-process.sh] %bTranscoding file..%b\n" "$GREEN" "$NC"
$__ffmpeg -i "${__file}" -vcodec h264 -acodec aac "${__base}.mp4" -report
# Remove the original recording file
slackSend "[${__base}] Moving originial file to postProcessBAK folder"
printf "[post-process.sh] %bRenaming originial file...%b\n" "$GREEN" "$NC"
# rm "${__file}"
# Return to the starting directory
cd "${PWD}"