Variations on a theme by Casey & Finch #3

For the third variation I began to explore rhythm further by repeating the random segments a number of times. I used the script from Variation #2 - although I only created 20 segments - and then repeated these between two and six times each.

Observations

This variation bears more resemblance to a skipping CD than the previous two. The possibility of this being performed by live musicians becomes impossible due to the very short length of some of the segments.

Code

This script requires libav to run and has been tested on Ubuntu 13.04.

#!/bin/bash #Usage: ./movie\_cut.sh /path/to/file.avi #e.g. ./movie\_cut.sh video.avi

filenumber=$(printf "%05d") while \[ $filenumber -le 20 \] do

#calculate the length of the video 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 | sed -e s/^/0/)

#define random duration (up to 0.999 seconds) duration=$(echo "0.$RANDOM")

#get path of file path=$( readlink -f "$( dirname "$1" )" )

#get filename minus extension file=$(basename "$1") filename="${file%.\*}"

#cut the video avconv -i $1 -ss $startPos -t $duration -qscale 0 -ab 384k -y "$path"/"$filenumber"\_"$filename"\_cut.avi

filenumber=\`expr $filenumber + 1\` filenumber=$(printf "%05d" $filenumber)

done

The following script was then run on the output files from the previous script. It creates numbered duplicates of the source files.

#!/bin/bash

for file in \*.avi do

#number of times to duplicate the file (between 1 and 6) max=$(shuf -i 1-6 -n 1)

number=1 while \[ $number -le $max \] do

#get path of file path=$( readlink -f "$( dirname "$file" )" )

#get filename minus extension file=$(basename "$file") filename="${file%.\*}"

#get extension extension="${file##\*.}"

#copy the file to a new file cp $file "$path"/"$filename"\_"$number".$extension

number=\`expr $number + 1\`

done

done