|
@@ -0,0 +1,42 @@
|
|
|
+#!/usr/bin/env bash
|
|
|
+
|
|
|
+if [ $# -ne 1 ]; then
|
|
|
+ echo "Usage: $0 <filename>"
|
|
|
+ exit 1
|
|
|
+fi
|
|
|
+
|
|
|
+if [ ! -f $1 ]; then
|
|
|
+ echo "$1 is not a file"
|
|
|
+fi
|
|
|
+
|
|
|
+file=$1
|
|
|
+
|
|
|
+FFMPEG="docker run -ti --rm -v $(pwd):/data -w /data linuxserver/ffmpeg"
|
|
|
+FFPROBE="docker run -ti --rm -v $(pwd):/data -w /data --entrypoint ffprobe linuxserver/ffmpeg"
|
|
|
+
|
|
|
+CLIP_LEN=60
|
|
|
+
|
|
|
+audio_len=$($FFPROBE -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $file | tr -d '\r\n')
|
|
|
+audio_len=${audio_len%.*}
|
|
|
+max_start=$(expr $audio_len - $CLIP_LEN)
|
|
|
+
|
|
|
+# first make a bunch of 60s clips with random start positions
|
|
|
+for i in $(seq 0 59); do
|
|
|
+ rand_start=$(($RANDOM % $max_start))
|
|
|
+ outfile="clip-$i.wav"
|
|
|
+ $FFMPEG -ss $rand_start -t 60 -i $file $outfile
|
|
|
+done
|
|
|
+
|
|
|
+# next loop over those clips and shrink them appropriately
|
|
|
+for i in $(seq 0 59); do
|
|
|
+ infile="clip-$i.wav"
|
|
|
+ outfile="clip-$i-adj.wav"
|
|
|
+ tempo=$(eval printf 'atempo=0.95\;%.0s' {1..$i})
|
|
|
+ $FFMPEG -i $infile -filter:a "$tempo" -vn $outfile
|
|
|
+done
|
|
|
+
|
|
|
+# stitch em together
|
|
|
+# Using a file here because i need to access it in docker
|
|
|
+>_concat; for i in $(seq 0 59); do echo "file clip-$i-adj.wav" >>_concat; done
|
|
|
+
|
|
|
+ffmpeg -f concat -safe 0 -i _concat -c copy powerhour.wav
|