I'm trying to make a bash script that takes arguments for start time and time, then takes an input file and output file name. If the start time and end time are left out, just execute it with input and output.
I've been trying to do it so I can use script.sh -t1 00:00:00 -t2 00:00:20 but so far I just have it as prompting for the values.
#!/bin/bash
read -ep "Enter path for the .mov-file: " file
IFS=: read -rp "Where should the trimming start? (HH:MM:SS): " shour smin ssec
IFS=: read -rp "When should the trimming end? (HH:MM:SS): " ehour emin esec
IFS=: read -rp "Output file: " output
start=$(( shour*3600 + smin*60 + ssec ))
end=$(( ehour*3600 + emin*60 + esec ))
duration=$(( end - start ))
ffmpeg -i "$file" -t "$duration" -c:v libvpx -crf 4 -b:v 1500K -vf scale=640:-1 -c:a libvorbis $output
Please point me in the right direction! I've tried using if/else to do it but it doesn't work.