Skip to content

Instantly share code, notes, and snippets.

@alexanderwallin
Created June 27, 2016 18:38
Show Gist options
  • Save alexanderwallin/1e56d8420bf394ac3ba2ff347dee39a2 to your computer and use it in GitHub Desktop.
Save alexanderwallin/1e56d8420bf394ac3ba2ff347dee39a2 to your computer and use it in GitHub Desktop.
Unpacks stems into folders with cover art and separate tracks using ffmpeg
#!/bin/bash
#
# Extracts tracks from stems files and puts them in folders
# named after the stem filenames.
#
for stem in *.mp4
do
name=${stem%\.*}
echo $name
# Create a directory
rm -R ./"$name"
mkdir $name
# Album cover
coverFilename="$name"/"$name"_cover.jpg
echo " - Extracting album cover to $coverFilename"
ffmpeg -i "$stem" -an -vcodec copy "$coverFilename"
# Audio tracks
for trackNo in 1 2 3 4
do
trackFilename="$name"/"$name"_"$trackNo".m4a
echo " - Extracting audio track $trackNo to $trackFilename"
ffmpeg -i $stem -map 0:$trackNo -vn "$trackFilename"
done
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment