Set of scripts used for various projects.
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
- #!/bin/sh
- # This is in the public domain.
- # written by John-Mark Gurney
-
- timetosec()
- {
- sec="${1##*:}"
- rem="${1%:*}"
- if [ x"$rem" = x"" -o x"$1" = x"$sec" ]; then
- hour=0
- min=0
- sec=${sec#0}
- else
- orig="$rem"
- min="${rem##*:}"
- rem="${rem%:*}"
- sec=${sec#0}
- if [ x"$rem" = x"" -o x"$min" = x"$orig" ]; then
- hour=0
- else
- hour="$rem"
- fi
-
- fi
-
- echo $(($hour * 60 * 60 + $min * 60 + $sec ))
- }
-
- failed()
- {
- echo failed
- exit 1
- }
-
- if [ x"$1" = x"-t" ]; then
- set -x
-
- x=$(timetosec 30)
- if [ x"$x" != x"30" ]; then
- failed
- fi
-
- x=$(timetosec 1:30)
- if [ x"$x" != x"$((60+30))" ]; then
- failed
- fi
-
- x=$(timetosec 1:01:30)
- if [ x"$x" != x"$((60*60+60+30))" ]; then
- failed
- fi
-
- exit 0
- fi
-
- if [ x"$#" != x"4" ]; then
- echo "Usage: $0 <inp> <start> <stop> <output>"
- exit 1
- fi
-
- inp="$1"
- start="$2"
- end="$3"
- out="$4"
-
- startsec=$(timetosec "$start")
- endsec=$(timetosec "$end")
-
- ffmpeg -ss "$startsec" -i "$inp" -t $(($endsec - $startsec + 1)) -codec copy "$out"
|