Skip to content

Instantly share code, notes, and snippets.

@XVicarious
Created September 6, 2019 15:09
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 XVicarious/050aa118475eb3a9ad3d5b1a65142574 to your computer and use it in GitHub Desktop.
Save XVicarious/050aa118475eb3a9ad3d5b1a65142574 to your computer and use it in GitHub Desktop.
convert a soundtract to individual flacs
function wav2flacs
if [ (count $argv) -lt 2 ]
if [ ! -e (basename -swav $argv[1])cue ]
echo "No cue file of same name as wav, please specify one."
end
set cue (basename -swav $argv[1])cue
else
set cue $argv[2]
end
set wav $argv[1]
set tmpDir (mktemp -d)
mkvmerge $wav --chapters $cue -o $tmpDir/(basename -swav $wav)mkv
mkvmerge -D -S $tmpDir/(basename -swav $wav)mkv --split chapters:all -o $tmpDir/split-%02d.mkv
set titles (grep -aE '\ TITLE' $cue | sed -E 's/(^[^"]+?"|"[^"]+?$)|\///g')
echo $titles[2]
for i in $tmpDir/split-*
set numb (echo $i | sed -E "s~$tmpDir/split-([[:digit:]]+).mkv~\1~")
ffmpeg -i $i $titles[$numb].flac
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment