Skip to content
Snippets Groups Projects
Commit 517512a6 authored by Isabella Skořepová's avatar Isabella Skořepová
Browse files

Quiet lvl 1 and file read

parent 3db2734f
No related branches found
No related tags found
No related merge requests found
......@@ -9,7 +9,7 @@ version() {
display_help() {
cat << EOH
Usage:
$0 [options] VIDEO-FILE TIMES-FILE
$0 [options] -i VIDEO-FILE -t TIMES-FILE
Video file will be split into parts at times specified in times-file
......@@ -20,10 +20,12 @@ Empty lines (except for trailing) will confuse this script
(Not implemented options are marked with !)
Options:
!-q --quiet Surpresses ffmpeg output. Put twice to surpress all output
!-d --debug Do not invoke ffmpeg and only show commands to run
-q --quiet Surpresses ffmpeg output. Put twice to surpress all output
-d --debug Do not invoke ffmpeg and only show commands to run
-v --version Shows version information
-h --help Shows this help message
-i --input Input video file (required)
-t --times Input times file (required)
Written by Jakub Skořepa (jakub at skorepa.info) in 2015-4
Distributed under:
......@@ -49,6 +51,14 @@ do
display_help
exit
;;
-i|--input)
file="$2"
shift
;;
-t|--times)
lengths="$2"
shift
;;
*)
echo "Warning: unknown option $key"
;;
......@@ -56,10 +66,37 @@ do
shift
done
exit
if [ -z "$file" ] && [ -z "$lengths" ]
then
echo "File and times file was not specified"
echo "See $0 --help for more information"
exit
fi
if [ -z "$file" ]
then
echo "File was not specified"
echo "See $0 --help for more information"
exit
fi
if [ -z "$lengths" ]
then
echo "Times file was not specified"
echo "See $0 --help for more information"
exit
fi
echo "ffmpeg -i \"$file\" -to "$(sed "1q;d" $lengths)" 1.mp4"
ffmpeg -i "$file" -to $(sed "1q;d" $lengths) 1.mp4
if [ ! $debug ]
then
if [ $quiet -ge 1 ]
then
ffmpeg -i "$file" -to $(sed "1q;d" $lengths) 1.mp4 > /dev/null 2>&1
else
ffmpeg -i "$file" -to $(sed "1q;d" $lengths) 1.mp4
fi
fi
N=$(cat "$lengths" | wc -l)
Nm=$[N-1]
for I in $(eval echo "{1..$Nm}")
......@@ -69,8 +106,24 @@ do
t0=$[t-10] # start time - 10
t1=$[t2-t0] # length of segment + 10
echo "ffmpeg -ss $t0 -i \"$file\" -ss 10 -to $t1 $I.mp4"
ffmpeg -ss $t0 -i "$file" -ss 10 -to $t1 "$I"".mp4"
if [ ! $debug ]
then
if [ $quiet -ge 1 ]
then
ffmpeg -ss $t0 -i "$file" -ss 10 -to $t1 "$I"".mp4" > /dev/null 2>&1
else
ffmpeg -ss $t0 -i "$file" -ss 10 -to $t1 "$I"".mp4"
fi
fi
done
t=$(sed "$N""q;d" "$lengths")
echo "ffmpeg -ss "$[t-10]" -i \"$file\" -ss 10 $N.mp4"
ffmpeg -ss $[t-10] -i "$file" -ss 10 "$N"".mp4"
if [ ! debug ]
then
if [ $quiet -ge 1 ]
then
ffmpeg -ss $[t-10] -i "$file" -ss 10 "$N"".mp4" > /dev/null 2>&1
else
ffmpeg -ss $[t-10] -i "$file" -ss 10 "$N"".mp4"
fi
fi
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment