
MP3 and FLAC audio formats Part 5

FLAC encoding and decoding
Let’s consider file compression with the FLAC encoder, which can be downloaded here. For it to work, we need the flac.exe file. If you run it without parameters, you will get a short help on using the encoder. For detailed help, type flac –help (the information will be displayed) or flac –help> usage.txt (the information will be displayed in the uses.txt file).
WAV to FLAC encoding with default compression ratio (5):
flac infile.wav
WAV to FLAC encoding with specified compression ratio:
flac -n infile.wav where n is a number from 0 (minimum compression) to 8 (maximum compression).
FLAC to WAV decoding:
flac -d infile.flac
To ensure that FLAC compresses the data without loss, you can use any software that can compare files bit by bit, for example the built-in Windows utility fc. For the experiment, select any WAV file and perform the following transformations on it: original.wav (original file)> compressed.flac (encode file to FLAC)> decompressed.wav (decode FLAC back to WAV). Next, compare original.wav and decompressed.wav using fc in binary comparison mode:
fc / b original.wav decompressed.wav
After the verification is complete, the utility will display the message “No differences found between files”, indicating your full identity. This means that when converting to FLAC and vice versa, not a single bit was lost, which needed testing. If you do the same experiment with MP3, the result will be completely different, there will be a lot of differences between the files.



