Variations on a theme by Casey & Finch #4

For the final variation I wanted to explore the linear progression of the video. That is, up till now all of the variations have jumped randomly between different parts of the video. A skipping CD will always attempt to play from start to finish, even if it does skip occasionally. So, for this variation I wrote a script that created sequenced segments of varying lenghts (between 0.1-0.99 seconds) and then repeats them up to six times.

Observations

This variation, like the last one, resembles a skipping CD. By sequencing the samples I’ve lost some of the unpredictable, YTP-style edits but have gained more clarity. It has also been pointed out (thanks Rosa!) that a skipping CD doesn’t always skip. There may be periods of it working followed by glitches/skipping.

[code language=”bash”]#Usage: ./movie_cut.sh /path/to/file.avi Clip-duration-in-seconds
#e.g. ./movie_cut.sh 4.01

#start position
startPos=0

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

#define random integer
rand=$RANDOM

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

#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)

#increment the start position of the next video by the duration of the previous video
startPos=$(echo "scale = 2; $startPos + $(echo "0.$rand")" | bc | sed -e s/^/0/)

done[/code]

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

[code language=”bash”]#!/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[/code]