Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[User Script] Organize, Trim, And Compress Your FLAC Files
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Multimedia
View previous topic :: View next topic  
Author Message
sirjaren
n00b
n00b


Joined: 13 Jun 2011
Posts: 3

PostPosted: Mon Jun 13, 2011 7:17 pm    Post subject: [User Script] Organize, Trim, And Compress Your FLAC Files Reply with quote

Version 0.17
Released: 11/19/2012

Screenshots
Screenshot 1
Screenshot 2
Screenshot 3
Screenshot 4
Screenshot 5
Screenshot 6

Now in Portage tree!!
Project Site

Gentooers, this is a shell script to make managing your FLAC library much easier. :D It's output is written to look similar to Portage's output (Gentoo fashion).

Dependencies:

Code:
- BASH 4 (or greater)
- FLAC
- Coreutils
- SoX (Optional)
- libpng (Required if SoX is used)
- auCDtect (Optional)

This script can be run on any system that supports the above dependencies (Linux, Mac OS X, Windows [with Cygwin], any BSD, etc).

Okay. An explanation of what this script does is in order. This script will check your FLAC files for errors and report them to you via a log file to your home directory. This script will also re-compress your FLAC files to the highest level of compression (level 8 ). During the compression, the flac command will verify it's output in order to test the integrity of the FLAC file(s). It would be unnecessary to then test the FLAC files if the compression was successful.

Also, this script has the options to retag your FLAC files. What this means is it will extract the tags from your FLAC files and remove the excessive tags. The default tags that are kept are specified in the help output of the script. You have the option of configuring which tags you want kept by editing the configuration part of the script located under USER CONFIGURATION (near the top). Next, the script will remove all the FLAC tags and re-tag them with the extracted tags.

The script has the option to remove the SEEKTABLE from each FLAC file. Modern decoders and players no longer _need_ this and it's removal will save some space. You'll know if you need it if you can no longer seek in the middle of a song. If you do need it, it's trivial to add it back in.

Also, we can remove the excess PADDING is removed from each FLAC file. This will result in a smaller FLAC file, but if you want to re-tag the file, keep in mind it will probably take a bit longer to do as the FLAC file will have to expand to accommodate the information being tagged.

In addition, this script can also check the MD5 Signature of each FLAC file and report it's findings via log file. What this means is it will check to make sure the MD5 signature is not unset (meaning it's not a string of zeros). A FLAC file with an unset MD5 Signature is not necessarily corrupt, it just means that it hasn't been encoded with a signature. A re-encoding of the file will force an MD5 Signature to be set. This option would normally be used by itself FIRST to see which files have an unset MD5 Signature.

All these options are of course optional and can be specified to your liking upon execution.

As you can see above, when compressing the FLAC files, a tag called COMPRESSION is added to the files. The field for this tag is "8". As there isn't a reliable way to tell which level a FLAC file is compressed at, this tag will alleviate that problem.


Last edited by sirjaren on Mon Nov 19, 2012 9:12 pm; edited 37 times in total
Back to top
View user's profile Send private message
beermad
n00b
n00b


Joined: 04 Dec 2011
Posts: 2
Location: Ipswich UK

PostPosted: Sun Dec 04, 2011 2:16 pm    Post subject: Very useful Reply with quote

Thanks for this, it's solved a problem I was having with my N900 not being able to read flac tags when there's a seekblock in the file.

A small fix you might want to add to the script.
Where you currently have
Code:
FIND_FLACS="$(find "$DIRECTORY" -name *.flac -print)"

it ought to read
Code:
FIND_FLACS="$(find "$DIRECTORY" -name "*.flac" -print)"

...with double quotes round *.flac
This is because without the double quotes the shell will expand the * and it won't behave as expected all the time.
Back to top
View user's profile Send private message
sirjaren
n00b
n00b


Joined: 13 Jun 2011
Posts: 3

PostPosted: Sun Dec 04, 2011 2:48 pm    Post subject: Reply with quote

Thanks for the feedback, beermad! I'm glad it has been useful for you.

I'm a bit curious on the double quotes issue you mentioned. I've done a few tests with it and I cannot find an instance where if I don't put quotes around
Code:
*.flac
, that I will have issues with any corresponding FLAC files.

Generally, I will obtain each filename from the
Code:
while read i
part, and in the process the quotes surround
Code:
$i
will allow spaces and whatnot to be parsed correctly. Without quotes around
Code:
$i
, I find that filenames with spaces give me issues (even with quotes around
Code:
*.flac
.

If you could give me a bit more info on what exactly happens to you without the quotes around
Code:
*.flac
, that would be great! Thanks again beermad!
Back to top
View user's profile Send private message
beermad
n00b
n00b


Joined: 04 Dec 2011
Posts: 2
Location: Ipswich UK

PostPosted: Sun Dec 04, 2011 3:04 pm    Post subject: Reply with quote

Hi again,

It just hit me that I'm getting this in just one specific case. That's when my current working directory contains flac files. That's when the shell expands the *.flac to all of the filenames that match it.

So when I'm in a directory full of flacs,
Code:
find . -name *.flac
find: paths must precede expression: 02 The Sheppards - How Do You Like It?.flac
Usage: find [-H] [-L] [-P] [-Olevel] [-D help|tree|search|stat|rates|opt|exec] [path...] [expression]

Whereas with quotes
Code:
find . -name "*.flac"
./21 Barbara Mercer - Happiness Is Here.flac
./07 J.J. Barnes - Please Let Me In.flac
./13 The O'jays - I'll Never Forget You.flac
./06 L.V. Johnson - Recipe.flac
./05 Martha Starr - Love Is The Only Solution.flac
./18 Edwin Starr - You're My Mellow.flac
./16 The Belles - Don't Pretend.flac
./20 Rose Batiste - Hit And Run.flac
./03 Jackie Lee - Oh, My Darlin'.flac
./10 Steve Mancha - He Stole The Love That Was Mine.flac
./08 Pat Lewis - No One To Love.flac
./17 Richard Temple - That Beatin' Rhythm.flac
./12 Andrea Henry - I Need You Like A Baby.flac
./09 Buddy Smith - When You Lose The One You Love.flac
./15 The Debonairs - Headache In My Heart.flac
./14 Melvin Davis - I Must Love You.flac
./22 The Incredibles - There's Nothing Else To Say.flac
./04 Emanuel Laskey - I'm A Peace Lovin' Man.flac
./11 Jackie Beavers - I Need My Baby.flac
./19 The Professionals - That's Why I Love You.flac
./02 The Sheppards - How Do You Like It?.flac
./01 Darrell Banks - Open The Door To Your Heart.flac


Hope this makes more sense.
Back to top
View user's profile Send private message
sirjaren
n00b
n00b


Joined: 13 Jun 2011
Posts: 3

PostPosted: Sun Dec 04, 2011 3:48 pm    Post subject: Thank you! Reply with quote

I see what you mean now! Thanks a lot for the help and feedback! Fix is applied with your name as the reference!

Thanks again!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Multimedia All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum