Nullpinter

Nullpinter

Across the Great Wall we can reach every corner in the world.
github

Automated handling of Amazon Music file MD5 inconsistency issue

When you obtain audio files from Amazon Music through certain special channels, you will find that the Hi-Res FLAC files have a different md5 compared to versions sold on other platforms, this is because of the leading empty samples. Therefore, removing the empty samples will achieve "Bit Perfect". Hence, this script is written to automate the processing of files with incorrect md5.

# This code is distributed under the Apache 2.0 License.
# author: nptr
$files = Get-ChildItem -Recurse -Filter *.flac | Select-Object FullName, BaseName
$files | ForEach-Object {
    $fullName = $_.FullName
    $fileName = $_.BaseName
    Write-Host Processing $fileName
    $flag = metaflac --show-tag=BP $fullName
    $res = metaflac --show-sample-rate $fullName
    $skip = 0
    switch ($res) {
        44100 { $skip = 286 }
        48000 { $skip = 312 }
        96000 { $skip = 624 }
        192000 { $skip = 1248 }
        Default { $skip = 0 }
    }
    if ($flag -ne "BP=1") {
        Write-Host SampleRate: $($res / 1000)kHz, skip $skip
        if ($skip -ne 0) {
            flac -8 --skip=$skip -f $fullName
            metaflac --set-tag=BP=1 $fullName
        }
    }
    else {
        Write-Host Skipping $fileName
    }
}

PowerShell 7 and metaflac are used in this script, I believe you can solve these two issues with your intelligence.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.