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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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