Skip to content

Instantly share code, notes, and snippets.

@mxbees
Created July 5, 2014 11:44
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save mxbees/b185fb35d1e6e1bb8820 to your computer and use it in GitHub Desktop.
clip movies
#!/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