-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvideo-clipper.sh
executable file
·39 lines (36 loc) · 972 Bytes
/
video-clipper.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
#!/bin/bash
source ~/Repositories/scripts/essential-functions
clipdir="$HOME/Videos/clips"
function ask-for-timestamps {
echolor yellow ":: Beginning timestamp:"
echolor blue "- Hour: " 1
read -r beg_hour
echolor blue "- Mins: " 1
read -r beg_mins
echolor blue "- Secs: " 1
read -r beg_secs
echolor yellow ":: Ending timestamp:"
echolor blue "- Hour: " 1
read -r end_hour
echolor blue "- Mins: " 1
read -r end_mins
echolor blue "- Secs: " 1
read -r end_secs
export t_beg="${beg_hour}:${beg_mins}:${beg_secs}"
export t_end="${end_hour}:${end_mins}:${end_secs}"
}
[[ -z "$2" ]] && {
echolor red ":: Input error."
exit
}
outname="$(kebab "$2")"
[[ -e "${outname}.mp4" ]] && {
echolor red ":: Clobber error 01!"
exit
}
[[ -e "$clipdir/$outname.mp4" ]] && {
echolor red ":: Clobber error 02!"
exit
}
ask-for-timestamps
ffmpeg -i "$1" -ss "$t_beg" -to "$t_end" "$clipdir"/"$outname".mp4