-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathreencode-hevc-videos
More file actions
executable file
·57 lines (47 loc) · 1.22 KB
/
reencode-hevc-videos
File metadata and controls
executable file
·57 lines (47 loc) · 1.22 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
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env bash
DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null 2>&1 && pwd)"
clear_line() {
printf "\r\033[2K"
}
print_status() {
printf "\e[3;4m%s\e[0m\r" "$1"
}
print_status_report() {
clear_line
print_status "$1"
}
print_status_success() {
printf "\e[30;42m %s \e[0m" "$1"
shift
if [ -z "$1" ]; then
printf " \e[4m%s\e[0m" "$*"
fi
printf "\n"
}
print_status_error() {
printf "\e[1;101m %s \e[0m\n" "$1"
}
FILES=()
if [ $# -eq 0 ]; then
print_status "Scanning..."
while IFS= read -r -d $'\0'; do
FILES+=("$REPLY")
done < <(find . -name "*.mp4" -maxdepth 1 -type f -print0 2>/dev/null)
print_status_report "Scanned"
else
FILES=("$@")
fi
processed=0
for filepath in "${FILES[@]}"; do
print_status "Checking types... ($processed/${#FILES[@]})"
filename=$(basename -- "$filepath")
filename="${filename%.*}"
HAS_HEVC="$(mediainfo --Inform="Video;%Format%" "$filepath" | grep -iE 'HEVC')"
if [ -n "${HAS_HEVC// /}" ]; then
printf "Transcoding \e[1;36;40m %s \e[0m... " "$filename"
"$DIR/reencode-video-file" "$filepath" 2>/dev/null >/dev/null
print_status_success "Done"
fi
((processed += 1))
done
clear_line