Nullpinter

Nullpinter

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

自动化处理Amazon Music文件MD5不一致问题

当你从某些特殊渠道拿到 Amazon Music 的音频文件的时候,你会发现其 Hi-Res FLAC 文件 md5 与其他平台售卖版本不同,这是因为其前面有空采样。因此只需去除空采样即可达到 “Bit Perfect”。故写这一脚本自动化处理具有错误 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
    }
}

用到了 PowerShell7 以及 metaflac,相信聪明的你能够解决这两个问题。

加载中...
此文章数据所有权由区块链加密技术和智能合约保障仅归创作者所有。