FLAC+CUE to multiple tracks
Let’s say we have a big single FLAC file we want to split into multiple files, we are on Fedora and we don’t want to use anything but the command line.
First of all:
[root@fedora ~]$ yum install lame ffmpeg shntool cuetools
To split the single FLAC file run:
[user@fedora ~]$ shnsplit -o flac -f file_name.cue -t "%n - %p - %t" file_name.flac
This will produce n single files, -t
parameter is used to specify file name format (in this case: track_number – performer – track_name).
To copy metadata from CUE to the single files run:
[user@fedora ~]$ cuetag.sh file_name.cue *.flac
The following script can be used to convert all the single FLAC files in MP3 (bitrate: 320kb/s) and also copying all the metadata.
Packages needed are lame
and id3lib
.
#!/bin/bash
for a in *.flac; do
# give output correct extension
OUTF="${a[@]/%flac/mp3}"
# get the tags
ARTIST=$(metaflac "$a" --show-tag=ARTIST | sed s/.*=//g)
TITLE=$(metaflac "$a" --show-tag=TITLE | sed s/.*=//g)
ALBUM=$(metaflac "$a" --show-tag=ALBUM | sed s/.*=//g)
GENRE=$(metaflac "$a" --show-tag=GENRE | sed s/.*=//g)
TRACKNUMBER=$(metaflac "$a" --show-tag=TRACKNUMBER | sed s/.*=//g)
DATE=$(metaflac "$a" --show-tag=DATE | sed s/.*=//g)
# stream flac into the lame encoder
flac -c -d "$a" | lame -b 320 --add-id3v2 --pad-id3v2 --ignore-tag-errors \
--ta "$ARTIST" --tt "$TITLE" --tl "$ALBUM" --tg "${GENRE:-12}" \
--tn "${TRACKNUMBER:-0}" --ty "$DATE" - "$OUTF"
done
To convert an ape file in flac run:
[user@fedora ~]$ yum install ffmpeg
[user@fedora ~]$ ffmpeg -i input.ape output.flac