Hydrogenaudio Forums

Lossless Audio Compression => FLAC => Topic started by: Brand on 2020-11-19 10:13:15

Title: How-to: Copy the MD5 checksum to a tag and compare it
Post by: Brand on 2020-11-19 10:13:15
How to copy the built-in FLAC MD5 audio checksum to the Comment tag and verify that it matches, using Mp3tag (https://www.mp3tag.de/en/index.html).
This is primarily intended to be used for [prior to] conversions from FLAC to FLAC (usually changing compression levels) or from FLAC to any lossless format and back to FLAC. As long as the Comment tag is carried over through the conversions, you have the confirmation that the audio data stayed the same.

Step 0 (optional) - Display the MD5 checksum in a column:
1. Right click on the top of the columns, select "Customize columns..." and make a New column.
2. Name: MD5 and Value: %_md5audio%.
You should now see the MD5 values for all FLAC files.

Step 1 - Copy the MD5 checksum to the Comment tag:
1. Select the track(s).
2. Click on the "Tag - Tag" button in the toolbar.
3. Field: COMMENT and Format string: %comment% '['MD5: %_md5audio%']'.
This will add the checksum at the end of the existing comments/content, like [MD5: 42B36D5....].

Step 2 - Check if the built-in MD5 checksum is included in the Comment tag:
1. Make a New column.
2. Name: MD5 check. Value: $ifgreater($strstr(%comment%,%_md5audio%),0,OK,ERROR).
If the exact MD5 checksum of a file exists also in the Comment tag, the column will show OK, otherwise it will show ERROR. The matching is case-sensitive. If you have a big list of files you can sort by column to separate the OKs and the ERRORs.

That's it. So far it's been working as intended for me, but let me know if you encounter any problems or have any suggestions.
Using the Comment tag for this might be less than ideal, because there's often content there. OTOH it seems like a safe option that should work across various audio formats and software without breaking stuff.
Title: Re: How-to: Copy the MD5 checksum to a tag and compare it
Post by: Brand on 2020-11-19 12:34:01
On using some other tag instead of the Comment... Apparently the FLAC (Vorbis) tagging system allows creating custom tags without breaking the FLAC format. So you could copy that MD5 data into your own custom tag, which could be called MD5CUSTOMTAG, for example.
In that case you might as well copy the MD5 value directly without any brackets and you can have a simpler formula in Mp3tag, like $if($eql(%MD5CUSTOMTAG%,%_md5audio%),OK,ERROR).

I converted such a FLAC to WavPack, MP3, AAC and Opus with Foobar and the custom tag was transferred as well and the files appear to work fine in a couple of Windows programs that I tried.
The only question is whether such files would work fine everywhere. I remember a case where a hardware MP3 player couldn't play MP3 files if they contained the disc number, for example, that's why I'm a bit careful.
But since the custom tag can be removed later, I think it's not a big deal. If someone knows more about this, let me know.
SimplePortal 1.0.0 RC1 © 2008-2021