Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#!/bin/bash
echo "file name"
read name
#both the 'start' and 'end' variables should be time stamps of the format hh:mm:ss
echo "start of clip"
read start
echo "end of clip"
read end
echo "output name"
read out
#this is for converting the times to seconds
timeS=`echo $start | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }'`
endS=`echo $end | awk -F: '{ print ($1 * 3600) + ($2 * 60) + $3 }'`
#this calculates the duration of the clip based on the time stamps (mainly because my version of ffmpeg on Debian 7 doesn't have the -to command
dur="$((endS - timeS))"
ffmpeg -ss $start -i $name -c copy -t $dur $out
#note: this only extracts the clip and does nothing else to the video, which makes it fast. You can, of course, edit this command to convert video formats, scale, and whatever else you can do with ffmpeg.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.