/
videowall
executable file
·117 lines (108 loc) · 3.02 KB
/
videowall
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
#!/bin/sh
# Run relative to script location
parent_path=$( cd "$(dirname "${BASH_SOURCE[0]}")" ; pwd -P )
cd "$parent_path"
usage() {
echo "usage: $0 [-ahrx] [-c HTML_color] [-f format] [-t duration]"
echo
echo " -a, --sort Play videos alphabetically."
echo " -c, --color HTML_color Tint video files. (Default: 3b1e00)"
echo " -f, --format format Set playlist format [m3u, xspf]."
echo " (Default: m3u)"
echo " -h, --help Display this message."
echo " -r, --recursive Include files in subfolders."
echo " -s, --speed speed Set playback speed. (Default: 0.67)"
echo " -t, --time duration Set duration of each video, in seconds."
echo " (Default: 30)"
echo " -x, --no-effects Remove all audio and video effects."
}
# Set defaults
playlist_format="m3u"
playlist_name="$(basename "$PWD")"
clip_duration_in_seconds=30
playlist_duration_in_hours=4
playback_speed=0.618
contrast=1.2
brightness=1.05
color_tint="3b1e00"
has_effects=true
is_alphabetical=false
is_recursive=false
# Process flags and override defaults
while [ "$1" != "" ]; do
case $1 in
-a | --sort)
is_alphabetical=true
;;
-c | --color)
opt="$1"
shift
if [[ ! "$1" =~ ^([[:xdigit:]]{6})$ ]]
then
echo "error: Option '$opt' requires a 6-digit HTML color."
usage
exit 1
fi
color_tint=$1
;;
-f | --format)
opt="$1"
shift
if [[ ! "$1" =~ ^(m3u|xspf)$ ]]
then
echo "error: Option '$opt' requires a playlist format [m3u, xspf]."
usage
exit 1
fi
playlist_format=$1
;;
-h | --help)
usage
exit 0
;;
-r | --recursive)
is_recursive=true
;;
-s | --speed)
opt="$1"
shift
if [[ ! "$1" =~ ^([+-]?[0-9]+\.?[0-9]*)$ ]]
then
echo "error: Option '$opt' requires a number. Normal speed is 1.0."
usage
exit 1
fi
playback_speed=$1
;;
-t | --time)
opt="$1"
shift
if [[ ! "$1" =~ ^([0-9]+)$ ]]
then
echo "error: Option '$opt' requires an integer duration."
usage
exit 1
fi
clip_duration_in_seconds=$1
;;
-x | --no-effects)
has_effects=false
;;
*)
echo "error: Unknown option or argument '$1'."
usage
exit 1
;;
esac
shift
done
echo "Generating playlist..."
python3 build_playlist.py $clip_duration_in_seconds $playlist_duration_in_hours "$playlist_name" $playlist_format $is_recursive $is_alphabetical
echo "Playing playlist..."
playlist_options="--playlist-autostart --fullscreen --no-osd --loop --no-random"
video_options=""
if $has_effects
then
video_options="--no-audio --rate=$playback_speed --video-filter extract:adjust --extract-component=0x$color_tint --contrast=$contrast --brightness=$brightness"
fi
/Applications/VLC.app/Contents/MacOS/VLC $playlist_options $video_options "$playlist_name.$playlist_format"