Description
Preface
Let me start by mentioning that I was very happy to read in the release notes for 1.4.3 that metaflac now provides a way to copy certain blocks of meta data via --list --data-format=binary
and --append
as I needed to write a script that can copy meta data from one file to another last week. Lucky timing indeed.
The problem at hand
While writing that script, there was one thing that irked me, namely that when I manually invoke metaflac --list "$FlacFile"
on a FLAC file to get an overview of the number and type of meta data blocks, hex dumps for binary data (such as embedded album art, which can have a size on the order of one hundred kilobyte) are displayed, which makes the output incredibly noisy and at least on Windows Terminal forces me to redirect the output to a file before being able to view it due to Windows Terminal having a very "analogue" scrolling speed...
I thus wanted to ask whether you could please make the hex dumps of any binary blob stored in a meta data block optional and by default skip its output either entirely or only print the first couple of bytes?
An example for where this could improve performance downstream
Making the metaflac --list
default output less verbose would also speed up scripts that parse it. In my example I am parsing its output to figure out the block numbers that I need to copy. In PowerShell my code that should copy all meta data except for the STREAMINFO
, which you cannot copy, and the SEEKTABLE
, which I do not want to copy, from $ReferenceFlac
to $TargetFlac
looks like this:
# We first transfer the tags from the VORBIS_COMMENT block...
$MetaFile = New-TemporaryFile | Rename-Item -NewName { [System.IO.Path]::ChangeExtension($_.Name, 'txt') } -PassThru
& metaflac.exe --export-tags-to="$MetaFile" "$ReferenceFlac"
& metaflac.exe --import-tags-from="$MetaFile" "$TargetFlac"
# ...and then we append any block that is not of type STREAMINFO, SEEKTABLE, or VORBIS_COMMENT:
& metaflac.exe --list --except-block-type=STREAMINFO,SEEKTABLE,VORBIS_COMMENT "$ReferenceFlac" `
| Select-String -Pattern '^METADATA block #(\d+)$' | ForEach-Object {
$BlockNum = $_.Matches.Groups[1].Value
Start-Process 'metaflac.exe' ('--list', '--data-format=binary', "--block-number=$BlockNum", "$ReferenceFlac") -RedirectStandardOutput "$MetaFile" -NoNewWindow -Wait
Start-Process 'metaflac.exe' ('--append', "$TargetFlac") -RedirectStandardInput "$MetaFile" -NoNewWindow -Wait
}
# Clean up temporary file:
Remove-Item "$MetaFile"
So every line of that hex dump output has to go through a regular expression that will effectively discard it anyway and would thus benefit from the output being less verbose.
(As a side note: From what I gather that should be the most effective and efficient way to copy metadata between two FLAC files using the 1.4.3 release. Feel free to let me know if there is a better way to do so. And apologies for creating such a verbose issue, but I figured that understanding what I am trying to do helps you with understanding why this is important for me.)
Activity