Print file names with duration for musicbrainz.org with this elegant one-liner:
for i in *mp3 ; \ do dur=$(ffprobe "$i" 2>&1 | \ grep Duration | \ perl -ne '/Duration: 00:(.*?)\./; print $1;'); \ echo "${i%%.mp3} $dur"; \ done
Print file names with duration for musicbrainz.org with this elegant one-liner:
for i in *mp3 ; \ do dur=$(ffprobe "$i" 2>&1 | \ grep Duration | \ perl -ne '/Duration: 00:(.*?)\./; print $1;'); \ echo "${i%%.mp3} $dur"; \ done
Picard, available here or maybe in the repository of your linux distribution (Arch Linux has it), is a great tool to tag your mp3-collection (if you don’t use beets), but it’s not very intuitive, so here are the instructions.
Click “Add Folder” to add a folder, oder “Add Files” to add single files. Most of the time they’ll show up under “Unmatched Files” on the left. Then select “Unmatched files” and click the button “Lookup”. Now Picard contacts musicbrainz.org and searches for the album.
After a while you should see the album name on the right pane. If you get an error that it couldn’t load the album information, fret not. Just hit CTRL-R until the error is gone.
Expand the album information. Now drag and drop the filenames from the left pane to their respective tracks on the right. Yes, there’s no other way to match the files! Once you’re done, click “Save” to tag.
If you want Picard to move and/or rename the files according to their track title and number, check Options -> Move Files and Options -> Rename Files. Select a destination folder in Options -> Options… -> File Naming, and a pattern in “Name files like this”.
The pattern controls how the files are named. I like this one for USB-Sticks (all in one line):
%albumartist% - %album%/$if($gt(%totaldiscs%,1),%discnumber%$num(%tracknumber%,2) - %title%, $num(%tracknumber%,2) - %title%)
Guess what it means 🙂
When splitting big mp3 files (like audiobooks) into digestible chunks (say 20 minutes) with ffmpeg, there are several things to keep in mind:
But do not fret. I put this all together in a quick and dirty quick and dirty perl script. First argument is the input file, second the base for output file names and third the base for the title tag:
$ splitmp3.pl "Big Input file.mp3" "Output file" "Name"
outputs files like this:
Output file - 01.mp3 Output file - 02.mp3 ...
with titles like this:
Name - 01 of 37 Name - 02 of 37 ...
That’s all, folks!
To convert a single flac file with a cue sheet to mp3, first split it up:
$ shnsplit -f <sheet.cue> <source.flac>
Then convert the wav-files to mp3 with ffmpeg:
for i in *.wav ; do ffmpeg -i ${i} -codec:a libmp3lame -qscale:a 2 ${i%%wav}mp3 ; done
Or, if you have individual flac files:
for i in *.flac; do ffmpeg -i ${i} -codec:a libmp3lame -qscale:a 2 ${i%%flac}mp3 ; done
qscale:a 2 produces mp3s with an average bitrate around 170-210 kbit/s. It should be close to lossless.