Skip to content

Instantly share code, notes, and snippets.

@hrpunio
Created February 7, 2012 23:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hrpunio/1762973 to your computer and use it in GitHub Desktop.
Save hrpunio/1762973 to your computer and use it in GitHub Desktop.
#!/bin/bash
#
# Usage: ffmpeg_cut.sh start-time stop-time file-in file-out
# where:
# start-time stop-time has the format: hh:mm:ss (hh,mm optional)
#
function cnt_sec () {
echo $1 | awk -F":" '{ if (NF>2) { sec += 60*60 * $(NF-2) } ;
if (NF>1) { sec += 60 * $(NF-1) } ;
if (NF>0) { sec += $NF } ; ## seconds
print sec }'
}
STRT_TIME=`cnt_sec $1`
STOP_TIME=`cnt_sec $2`
DURATION=$(($STOP_TIME-STRT_TIME))
echo $DURATION
ffmpeg -ss $1 -t $DURATION -i $3 $4
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment