5

I know from [Sources], that FLAC computes CRC and MD5.

What I am afraid that flac --test only does CRC test - as stated in man flac : same as -d except no decoded file is written .

How to check flac file correctness, using MD5 of raw PCM placed in STREAMINFO in given .flac file ?

If flac --test makes job, are there any reliable (like in flac documentation) references that shows it?

Sources:

http://en.wikipedia.org/wiki/Free_Lossless_Audio_Codec we can find:

FLAC uses CRC checksums for identifying corrupted frames when used in a streaming protocol, and also has a complete MD5 hash of the raw PCM audio stored in its STREAMINFO metadata header.

http://flac.sourceforge.net/comparison.html

By default when processing files, flac computes the MD5 sum while encoding and decoding.

To see md5sums in STEAMINFO we can use:

$ metaflac --show-md5sum *.flac 

3 Answers 3

7

The most reliable source is the source code itself, and it does suggest that MD5 stored in STREAMINFO is checked by default.

3

http://wiki.etree.org/index.php?page=FlacFingerprint shows this info:

Instead, when you decompress or use flac's Test feature, FLAC automatically verifies each file against an internal checksum stored in the file.

Note that a flac fingerprint isn't a checksum of the encoded flac data - it's a checksum of the decoded music data. So to test the file, flac decodes the data in the file and verifies that the checksum of the music data matches the (internally stored) flac fingerprint.

This has a few interesting implications:

When flac decodes, it checks the file (and each part of the file) against the internal checksum data. If a flac file decodes without error, it's a good file - as long as you are using an application that reports decoding errors!

This seems to imply that both the CRC and MD5 are checked since the CRCs are only for frames. I did a little test and got 2:FLAC__STREAM_DECODER_ERROR_STATUS_FRAME_CRC_MISMATCH, which is expected. Looking at the code, the following implies that it is always checked:

/* * undocumented debugging options for the test suite */ { "no-md5-sum" , share__no_argument, 0, 0 }, 

And by default it is set:

FLAC__stream_decoder_set_md5_checking(decoder_session->decoder, true); 

Set the "MD5 signature checking" flag. If true, the decoder will compute the MD5 signature of the unencoded audio data while decoding and compare it to the signature from the STREAMINFO block, if it exists, during FLAC__stream_decoder_finish().

It's as the answer from sendmoreinfo indicates:

The most reliable source is the source code itself, and it does suggest that MD5 stored in STREAMINFO is checked by default.

1
  • 2
    Nowadays mediainfo prints the md5 hex section of flac files and ffmpeg writes them correctly too and in fact it is the same as (for 16 bit flac) ffmpeg.exe -i HDCD.flac -vn -f md5 - and for 24 bit flac ffmpeg.exe -i News.flac -vn -c:a pcm_s24le -f md5 - Commented Mar 1, 2023 at 3:00
-1

This may help.

https://www.quickhash-gui.org/

FLAC uses CRC checksums for identifying corrupted frames when used in a streaming protocol, and also has a complete MD5 hash of the raw PCM audio stored in its STREAMINFO metadata header.

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.