-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathytclip
More file actions
executable file
·48 lines (42 loc) · 1.6 KB
/
ytclip
File metadata and controls
executable file
·48 lines (42 loc) · 1.6 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
#!/bin/bash
printf "%s\n" "$1"
[ -z "$1" ] && printf "Insert Link\n" 2>&1 && exit || link="$1"
shift
[ $# -eq 1 ] && printf "No positional Arguments\n" 2>&1 && exit
while [ $# -gt 1 ]; do
case $1 in
a)
shift
isAudio="1"
;;
s)
shift
# Check if arguemnt has letters
printf "%s\n" "$1" | grep '[a-zA-Z]' && printf "Invalid Start Time\n" 2>&1 && exit
startTime="-ss $1"
shift
;;
t)
shift
# Check if arguemnt has letters
printf "%s\n" "$1" | grep '[a-zA-Z]' && printf "Invalid End Time\n" 2>&1 && exit
endTime="-t $1"
shift
;;
*)
[ -n "$startTime" ] && [ -n "$endTime" ] && break
;;
esac
done
[ -z "$startTime" ] && [ -z "$endTime" ] && printf "No positional Arguments\n" 2>&1 && exit
# Get last argument
[ -z "${@: -1}" ] || [ "$0" == "${@: -1}" ] && printf "Missing filename\n" 2>&1 && exit || filename="${@}"
#ffmpeg -probesize 50M -i "$link" $startTime $endTime -c:v copy -c:a copy -bsf:a aac_adtstoasc -f mp4 $filename
if [ "${isAudio}" == "1" ]; then
printf "%s\n" "${isAudio}"
ffmpeg -probesize 50M -i "$link" $startTime $endTime -vn -c:a copy -avoid_negative_ts make_zero -shortest -bsf:a aac_adtstoasc "$filename"
else
ffmpeg -probesize 50M -i "$link" $startTime $endTime -c:v copy -c:a copy -avoid_negative_ts make_zero -shortest -movflags +faststart -bsf:a aac_adtstoasc -f mp4 "$filename"
fi
# debuging
# printf "$link ||| $startTime ||| $endTime ||| $filename\n"