Skip to content

Instantly share code, notes, and snippets.

@jadedgnome
Forked from mxbees/get-teh-clip.sh
Created July 27, 2014 12:48
Show Gist options
  • Save jadedgnome/8339c3864b2f7cb54b1a to your computer and use it in GitHub Desktop.
Save jadedgnome/8339c3864b2f7cb54b1a to your computer and use it in GitHub Desktop.
#!/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