Jump to content

Audio encoding guide (FLAC & MP3)


Steve

Recommended Posts

Another one that I wrote for another site..........

 

Encoding method 1: Lossy encoding

 

Lossy encoding takes an audio file - a WAV file, for example - and strips some of the audio information out of it in order to try and make it smaller. The lower the bitrate you use for encoding, the more information is stripped away. Strip too much away (say, by encoding to 32 Kbps MP3) and you can clearly hear the difference between the original file and the encoded one. For music that we use for DJing and for listening to for pleasure, the idea is for your encoded files to be "transparent", i.e. indistinguishable from the original source files. Once the audio information has been stripped out, it can't be put back, therefore you can't just convert a 128 Kbps MP3 file to a 320 Kbps MP3 file to make it higher quality.

 

Examples of lossy encoding formats are MP3, Ogg Vorbis and WMA.

 

Advantages = Very good file size to quality ratio. MP3 is everywhere, so you should have very few compatibility issues with hardware and software based players. If you distribute a mix as an MP3, people know what it is and know how they can play it. Supports tagging.

 

Disadvantages = Lowers the bitrate of your files by its very nature, although whether this is noticeable depends largely on the bitrate used, the equipment used to play back the files and your own hearing.

 

Encoding method 2: Lossless encoding

 

Lossless encoding works in a different way to lossy encoding. It still shrinks the source files down, but none of the original audio information is stripped away.

 

Examples of lossless encoding formats are FLAC, APE and Apple Lossless.

 

Advantages = It contains all of the audio information that the source file contains, so there is never any quality loss. Supports tagging.

 

Disadvantages = Doesn't shrink files down as much as lossy encoding does. Even the most popular lossless formats are nowhere as popular as MP3, therefore compatibility with gear may be more of an issue and people may not know what to do with, for example, a FLAC file, if you send them a mix in that format.

 

Which formats are the best?

 

It's always hard to say what's "the best", but for the purposes of this guide I'm going to focus on MP3 and FLAC. MP3 is very well supported and well used by DJs and FLAC is a free lossless encoder that is supported by various operating systems and some DJ equipment.

 

So, lossy Vs. lossless? Which should I use?

 

There is no definitive answer to this. Always be careful when doing your own tests, because bias may be a factor unless you do a blind test, for instance, some people want to think that they can hear a difference between a song at 320 Kbps MP3 and the same song in FLAC format so they convince themselves that they can, even though they can't. A double-blind abx test (Google it!) is really the only legitimate way of testing without bias creeping in.

 

If you do tests of your own, you are not necessarily listening for the file that sounds "better". Good encoding is transparent, so you should hear no difference between the source file and the encoded file. Let's say, for example, that you encode a WAV file to MP3 and you can hear the difference, but you think the MP3 file sounds better. The results of that are actually contrary to what you might assume as the MP3 file at that given bitrate has failed to produce a transparent encode, therefore that is a bad result, not a good one. It is when you can hear no difference between the source file and the encoded file that you should consider that particular codec/bitrate a success.

 

A quick word on "quality".........

 

Audio encoding is GIGO, which means "garbage in, garbage out". If you rip a piece of scratched vinyl using some $10 hi-fi with a beaten up old needle, just because you have a WAV file in front of you it doesn't mean that it's good quality. The quality of the source file is very important.

 

How do I encode files to MP3?

 

Not all MP3 files are the same. Over the years there have been various MP3 encoders created by different people/companies and various versions of those encoders. Some are better than others. LAME is regarded by many as the best encoder for creating MP3 files. A huge amount of work has gone into it and many tests have been done to check for the transparency of encodes created with LAME. For that reason, I would recommend using it. The current version is 3.99.4.

 

There are various ways to encode files to MP3 using LAME. You can download the lame.exe/lame_enc.dll file which you may be able to use with existing software that you have: -

 

http://www.rarewares...lame-bundle.php

 

Or you can use a stand-alone application that will encode files to MP3 using the latest version of LAME, LameDropXPd, for example: -

 

http://www.rarewares...p3-lamedrop.php

 

Which settings should I use when encoding files to MP3?

 

There are 3 main methods of encoding MP3s: -

 

CBR = Constant bitrate

VBR = Variable bitrate

ABR = Average bitrate

 

The most commonly used methods are CBR and VBR.

 

CBR = This is where you set a bitrate, 320 Kbps for example, and the whole file is encoded at that bitrate. This gives you the highest technical quality for MP3, but it is also wasteful in that if there is silence in the song, or a section where just hi-hats are playing, then that will be encoded at 320 Kbps too.

 

VBR = With VBR you choose a preset, with V0 being the highest quality, followed by V1, V2 etc. The bitrate will change depending on the quality of the music, so if there was silence in a song or sections where the song isn't that "busy", the bitrate would go down during that section, then during "busy" sections of the song it would go up.

 

Here is what the Hydrogen Audio Wiki says about MP3 encoding: -

 

The rule of thumb when considering encoding options: at a given bitrate, VBR is higher quality than ABR, which is higher quality than CBR (VBR > ABR > CBR in terms of quality). The exception to this is when you choose the highest possible CBR bitrate, which is 320 kbps (-b 320 = --alt-preset insane), but this produces the largest filesizes for doubtful audible benefit.

 

One consideration when choosing between CBR and VBR is how your gear handles VBR files. All software based players will handle them fine and so will DVS, but some CDJs may have issues with them, so bear that in mind.

 

Once you've decided on CBR or VBR (and you can try both to test them out), you then need to choose a bitrate. LAME is considered transparent with most music when using the VBR V2 setting, so I would use that as your minimum setting. For CBR I would go with 256 or 320 Kbps, but generally I see no good reason to use CBR over VBR (other than the compatibility issue I mentioned) so I personally always use VBR. Also, remember that the bitrates I'm recommending are just a guide. There is no set in stone answer to this, but I favour the highest bitrates if I'm using MP3 as I don't want to risk the quality of my music or mixes being degraded due to using too low a bitrate.

 

How do I encode files to FLAC?

 

Much like MP3, there are various ways to do it, including using the FLAC excutable with software you already have, and using stand-alone software.

 

FLAC software is available here for free for a range of operating systems, including Windows, OS X and Linux: -

 

http://flac.sourcefo...t/download.html

 

What settings should I use when encoding files to FLAC?

 

Things are a bit easier with FLAC, because there are no settings that affect the quality. Lossless is lossless! You can adjust the "level", but all that does is affect the compression level. Level 8 is the highest and gives you the smallest file sizes at the expense of taking a little longer to encode your files. With a fast computer, you really won't see any noticeable difference by selecting different levels in FLAC and the file size difference between the levels isn't great anyway, but I always use level 8 as that shrinks the files the most.

 

What about tagging?

 

Both FLAC and MP3 support tagging, so it's always a good idea to tag your files/mixes properly. I run Windows, so I use a free program called MP3Tag to tag files: -

 

http://www.mp3tag.de/en/

 

I wrote a guide on how to use some of the advanced features of MP3Tag here: -

 

http://www.digitalvertigo.co.uk/forum/index.php?showtopic=28368

 

Final words..............

 

Here's a summary of how to get the best out of your audio: -

 

1. Use the best quality source files that you can find. Remember, encoding is GIGO! Original CDs are great. Quality vinyl rips are great. WAV files bought from a reliable source are usually always great.

 

2. Make your own mind up on whether to use lossless or lossy and use the most recent version of the encoder, as these things have been finely tuned and tweaked over the years. Using an old encoder or a really crappy encoder that's long been superceded will give you worse quality encodes.

 

3. If you go with lossy, use a nice high bitrate to minimise the risk of your audio files being degraded. Also, remember that with lossy encoding, when audio information is stripped out, it can't be put back! Never encode the sole master copy of your latest and greatest mix to MP3 using a setting that will delete the source file, cos if you're not happy with the results, there's no going back.

 

4. Tag your files properly and it makes music management much easier.

Link to comment
Share on other sites

  • 4 weeks later...
  • 2 months later...

this is a great guide man.

pity i didn't have it when i was ripping senseless a few years ago...

 

cheers for the tagging info, thats what i need now..

Link to comment
Share on other sites

Excellent write up. I wonder how Sound Forge compares to Lame. I have been using it for years for recording and converting.

 

What encoder does it use? You could perhaps configure it to use LAME instead.

 

I don't see the point in any lossy format. Why?

 

I'd love to see a lossless codec take over from MP3 as the "standard". I only use MP3 for tunes on my phone, on a USB stick for my car stereo, and for distributing mixes on the web. Memory cards are getting so large now that I don't really need to do those first 2 things any more.

Link to comment
Share on other sites

It's just a matter of time, I think. It was about 1997 when I first started getting lossy files, and they were wavs, not mp3s, but compressed nonetheless. It was just nice to have songs. 15 years later, I think mp3 is pretty much done; there's no real reason waiting 10 seconds instead of 5 seconds to get a song is a bad thing, surely? Now alac is open source and considering how efficient it is, it's up to developers to write it - or another similar format - into future devices. alac/flac is half size of wav, and the only disadvantage of wav is that metadata is lacking in this broadband enabled age...

 

let's burn something. people listen when things are on fire...

Link to comment
Share on other sites

Apparently it is a violation of some laws or some shit to use Lame with commercial software (not that I really care) and Sound Forge can only use it's Fronhaufer encoder. From what I read though it is equally as good or better than Lame. Who knows.

Link to comment
Share on other sites

@Chris - I think MP3 is too ingrained. If at all, I think it will only be replaced if another codec is invented (either lossy or lossless) that's just crazy efficient at compressing files. One other possibility is if someone like Apple lead the way and said "it's ALAC only from now on when you buy from iTunes", but I can't see any big store ever doing that.

 

@Lotus - AFAIK, the FhG codec hasn't been updated for over 4 years. There are listening tests on the LAME SourceForge page that show its superiority over FhG in certain cases. Fraunhofer invented the MP3 codec, but from what I have read (which is quite a lot, but that doesn't make it right, haha), LAME is a superior codec today.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...