Skip to content

Instantly share code, notes, and snippets.

@hellocatfood
Last active December 17, 2015 00:39
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 hellocatfood/5522291 to your computer and use it in GitHub Desktop.
Save hellocatfood/5522291 to your computer and use it in GitHub Desktop.
A script to perform a random cut on a video By Antonio Roberts | www.hellocatfood.com Usage: ./movie_cut.sh /path/to/avi/file Clip-duration-in-seconds e.g. ./movie_cut.sh 4.01 Works best on avi files requires avconv
#!/bin/bash
#A script to perform a random cut on a video
#By Antonio Roberts | www.hellocatfood.com
#Usage: ./movie_cut.sh /path/to/avi/file Clip-duration-in-seconds
#e.g. ./movie_cut.sh 4.01
#Works best on avi files
bitRate=$(avprobe $1 2>&1 | grep bitrate | cut -d ':' -f 6 | sed s/"kb\/s"//)
length=`expr $(avprobe -loglevel error -show_streams $1 | grep duration | cut -f 2 -d = | head -1 | cut -d "." -f 1) \* 100`
#start position
startPos=$(echo "scale=2;$(shuf -i 1-$length -n 1) / 100" | bc)
#duration
duration=$2
avconv -ss $startPos -i $1 -t $duration -b "$bitRate"k "$1"_cut.avi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment