Skip to content

Instantly share code, notes, and snippets.

@rileyjshaw
Last active October 30, 2023 13:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rileyjshaw/ece29a93b09d6d1d1f6ab787b86d5812 to your computer and use it in GitHub Desktop.
Save rileyjshaw/ece29a93b09d6d1d1f6ab787b86d5812 to your computer and use it in GitHub Desktop.
I have a folder with every Fabriclive set split into individual files. This creates a merged track for each set, with the title spoken at the start of the track.
#!bin/bash
for d in */; do
cd "$d"
title=$(echo "$d" | sed 's/\./ /' | sed 's/ \[.*//g')
echo "$title" | sed 's/FABRICLIVE/Fabric lyve/' | sed -r 's/\(([0-9]+)\)/in \1/g' | sed -r 's/ 0+([1-9][0-9]*)/ \1/g' | say -v Serena -o "00. Title.aiff"
ffmpeg -i "00. Title.aiff" -acodec libmp3lame -ab 192000 -ar 44100 -ac 2 "00. Title.mp3"
command ls -1 *.mp3 | sed s/\'/\'\\\\\'\'/g | awk '$0="file \047"$0"\047"' >> tracklist.txt
ffmpeg -f concat -safe 0 -i tracklist.txt -c copy "../../Merged with titles/$title.mp3"
rm "00. Title.aiff"
rm "00. Title.mp3"
rm tracklist.txt
cd ..
done
@rileyjshaw
Copy link
Author

A quick modification to add spoken titles to a flat folder of MP3s in-place:

# bin/bash

# For all mp3s in the current directory:
for f in *.mp3; do
  echo "${f%.*}" | say -v Serena -o "_title.aiff"
  ffmpeg -i _title.aiff -acodec libmp3lame -ab 192000 -ar 44100 -ac 2 _title.mp3
  ffmpeg -i "$f" -acodec libmp3lame -ab 192000 -ar 44100 -ac 2 _content.mp3
  ffmpeg -i 'concat:_title.mp3|_content.mp3' -acodec copy _merged.mp3
  mv _merged.mp3 "$f"
  rm _title.aiff _title.mp3 _content.mp3
done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment