-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathled-movie-convert
125 lines (103 loc) · 4.05 KB
/
led-movie-convert
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
118
119
120
121
122
123
124
125
#!/bin/bash
# エンコード後のファイルを置くフォルダ
path="/home/pi/movieplayer/"
# バージョン
version="2.2"
if [ $# -eq 5 ]; then
# 動画の幅
width=$5
# 動画の高さ
height=$6
else
# 動画の幅
width=192
# 動画の高さ
height=108
fi
mkdir -p ${path}
if [ $# -ne 4 -a $# -ne 6 ]; then
echo "" 1>&2
echo "---------------------------------------------------" 1>&2
echo " Error: Argument is missing or too many." 1>&2
echo " Usage: Download :" 1>&2
echo " 1. led-movie-convert [Download URL] download auto false" 1>&2
echo " 2. led-movie-convert [Download URL] download auto true" 1>&2
echo " 3. led-movie-convert [Download URL] download \"[File name (no extension)]\" false" 1>&2
echo " 4. led-movie-convert [Download URL] download \"[File name (no extension)]\" true" 1>&2
echo " 5. led-movie-convert [Download URL] download \"[File name (no extension)]\" false" 1>&2
echo " [Movie width] [Movie height]" 1>&2
echo " 6. led-movie-convert [Download URL] download \"[File name (no extension)]\" true" 1>&2
echo " [Movie width] [Movie height]" 1>&2
echo " Localfile :" 1>&2
echo " 1. led-movie-convert [Localfile path] file auto false" 1>&2
echo " 2. led-movie-convert [Localfile path] file auto true" 1>&2
echo " 3. led-movie-convert [Localfile path] file \"[File name (no extension)]\" false" 1>&2
echo " 4. led-movie-convert [Localfile path] file \"[File name (no extension)]\" true" 1>&2
echo " 5. led-movie-convert [Localfile path] file \"[File name (no extension)]\" false" 1>&2
echo " [Movie width] [Movie height]" 1>&2
echo " 6. led-movie-convert [Localfile path] file \"[File name (no extension)]\" true" 1>&2
echo " [Movie width] [Movie height]" 1>&2
echo "" 1>&2
echo " Please Retry... m(__)m" 1>&2
echo "---------------------------------------------------" 1>&2
echo "" 1>&2
exit 1
fi
echo ""
echo "---------------------------------------------------"
echo " LED-Movie-Convert v"${version}
echo "---------------------------------------------------"
if [ "$2" = "download" ]; then
echo " Downloading..."
echo ""
if [ "$3" = "auto" ]; then
filename="${path}$(youtube-dl --get-title $1)"
else
filename=${path}$3
fi
youtube-dl -c -f "bestvideo[ext=mp4]+bestaudio[ext=m4a]/best[ext=mp4]/" -o "${filename}_orig.mp4" $1
echo ""
elif [ "$2" = "file" ]; then
if [ "$3" = "auto" ]; then
replace=$(echo "$1" | sed 's/\.[^\.]*$//')
filename=$1
filename_=${path}$(basename "${replace}")
else
filename=$1
filename_=${path}$3
fi
fi
if [ "$4" = "true" ]; then
contrast=",eq=saturation=1.4:contrast=1.5:brightness=-0.2"
else
contrast=""
fi
echo " Filename: "${filename}
echo " Width : "${width}
echo " Height : "${height}
echo "---------------------------------------------------"
echo " Converting..."
echo ""
if [ "$2" = "download" ]; then
ffmpeg -y -i "${filename}_orig.mp4" -vcodec libx264 -vf scale=${width}:${height}${contrast} "${filename}.mp4"
echo ""
ffmpeg -y -i "${filename}_orig.mp4" -vn -af dynaudnorm -ac 2 -ar 44100 -ab 128k "${filename}.mp3"
rm -r "${filename}_orig.mp4"
elif [ "$2" = "file" ]; then
ffmpeg -y -i "${filename}" -vcodec libx264 -vf scale=${width}:${height}${contrast} "${filename_}.mp4"
echo ""
ffmpeg -y -i "${filename}" -vn -af dynaudnorm -ac 2 -ar 44100 -ab 128k "${filename_}.mp3"
fi
echo ""
echo "---------------------------------------------------"
echo " Convert: "
if [ "$2" = "download" ]; then
echo " ${filename}.mp4"
echo " ${filename}.mp3"
elif [ "$2" = "file" ]; then
echo " ${filename_}.mp4"
echo " ${filename_}.mp3"
fi
echo "---------------------------------------------------"
echo ""
exit 0