-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflv2mp4.sh
45 lines (31 loc) · 946 Bytes
/
flv2mp4.sh
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/bash
# annie convert and sort
flv_search_convert() {
IFS=$(echo -en "\n\b")
for element in `ls "${1}"`; do
# echo "Cur Element: ${element}"
dir_or_file="${1}/${element}"
if [ -d "${dir_or_file}" ]; then
echo " --- DIR ${dir_or_file} ---"
flv_search_convert "${dir_or_file}" "${2}"
elif [ -f "${dir_or_file}" ]; then
echo " --- FILE ${dir_or_file} ---"
suffix="${dir_or_file##*.}"
if [ ${suffix} = "flv" ]; then
output=$(basename "$dir_or_file" .flv).mp4
dirname=$(dirname "$dir_or_file")
echo " outputname: ${output}"
echo " dirname: ${dirname}"
ffmpeg -i "${dirname}/${element}" -c copy -movflags +faststart -y "${dirname}/$(basename "$element" .flv).mp4"
if [[ ${2} = "N" || ${2} = "n" ]]; then
rm "${dirname}/${element}"
fi
fi
fi
done
}
main() {
read -p "Keep original flv files? (Y/N) " keep_flv
flv_search_convert "." "${keep_flv}"
}
main