2 Commity 31cbfd98be ... 91f8ff7b65

Autor SHA1 Wiadomość Data
  Joe Ceresini 91f8ff7b65 Add support for a separator/drink indicator 3 lat temu
  Joe Ceresini c33e65fe9a Fix filter separator 3 lat temu
1 zmienionych plików z 15 dodań i 9 usunięć
  1. 15 9
      powerhour.sh

+ 15 - 9
powerhour.sh

@@ -1,7 +1,7 @@
 #!/usr/bin/env bash
 
-if [ $# -ne 1 ]; then
-  echo "Usage: $0 <filename>"
+if [[ $# -lt 1 || $# -gt 2 ]]; then
+  echo "Usage: $0 <filename> <separator>"
   exit 1
 fi
 
@@ -10,14 +10,14 @@ if [ ! -f $1 ]; then
 fi
 
 file=$1
+sep=$2
 
 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%.*}
+audio_len=$($FFPROBE -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 $file | tr -d '\r\n' | sed 's/\..*$//')
 max_start=$(expr $audio_len - $CLIP_LEN)
 
 # first make a bunch of 60s clips with random start positions
@@ -29,14 +29,20 @@ 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})
+  outfile="clip-$i.wav"
+  infile="_$outfile.tmp"
+  mv $outfile $infile
+  tempo=$(eval printf 'atempo=1.1,%.0s' {1..$i} | sed 's/,$//')
   $FFMPEG -i $infile -filter:a "$tempo" -vn $outfile
+  rm $infile
 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
+>_concat
+for i in $(seq 0 59); do
+  echo "file clip-$i-adj.wav" >>_concat
+  [ "$sep" != "" ] && echo "file $sep" >>_concat
+done
 
-ffmpeg -f concat -safe 0 -i _concat -c copy powerhour.wav
+$FFMPEG -f concat -safe 0 -i _concat -c copy powerhour.wav