I convert my lossless music to Apple Lossless (ALAC) for easy playback on my Apple devices. The sourcefiles are mostly FLAC files. In order to verify the music conversion and check for bitrot later on, one could extract the md5 hash from the FLAC source file and add it as Item Flexible Attribute for later verification.
The metaflac binary (part of flac) alllows for md5 extraction with the command:
metaflac --show-md5sum FLACfile
and ffmpeg can calculate a files (audiostream) md5 using the command:
ffmpeg -i Musicfile -vn -f hash -hash md5 -
I have been trying to create a conversion script for the convert plugin to extract the flac’s hash and write it to the beets library, but have not succeeded so far. This is the convert command:
command: /Users/user/convert_flac.sh $source $dest
and this is the conversion script:
function source_hash { metaflac --show-md5sum --no-filename $1 } src_hash=$( source_hash $1 ) beet modify 'source_hash='$src_hash path:$1 ffmpeg -i $1 -y -vn -acodec alac $2
How could one go about to get the desired behavior? Is this possible using the convert plugin?
Any help with this would be very welcome.