Windows Windows 10 BUG会破坏FLAC音频文件 现已修复( 二 )


{
return $ false
}
# Passing these checks means that we likely have a stream info header and can rebuild the file
Write-Output "File Stream Information"
Write-Output "Sample Rate: $ sampleRate"
Write-Output "Audio Channels: $ channelCount"
Write-Output "Sample Depth: $ bitsPerSample"
Write-Output "MD5 Audio Sample Hash: $ MD5Hash"
return $ true
}
if ($ choice -eq 0)
{
Copy-Item $ FullPath -Destination $ BackupLocation -Force
$ stream = [System.IO.File]::Open( $ FullPath, [System.IO.FileMode]::Open)
$ stream.Seek(4, [System.IO.SeekOrigin]::Begin)
while ($ stream.ReadByte() -eq 0) {}
# We now need to figure out where a valid FLAC metadata frame begins
# We are likely pointing to the last byte of the size member so we'll seek back 4 bytes and retry
$ flacDataStartPosition = $ stream.Position - 4
$ stream.Seek( $ flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
while (-not(ParseStreamInfoMetadataBlock( $ stream)))
{
$ flacDataStartPosition = $ flacDataStartPosition + 1
$ stream.Seek( $ flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
【Windows|Windows 10 BUG会破坏FLAC音频文件 现已修复】}
# Insert the start code
$ stream.Seek( $ flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
if (Test-Path "$ FullPath.tmp")
{
Remove-Item "$ FullPath.tmp"
}
$ fixedStream = [System.IO.File]::Open(" $ FullPath.tmp", [System.IO.FileMode]::CreateNew)
[byte[]] $ startCode = [char[]]('f', 'L', 'a', 'C');
$ fixedStream.Write( $ startCode, 0, $ startCode.Length)
$ stream.CopyTo( $ fixedStream)
$ stream.Close()
$ fixedStream.Close()
Move-Item -Force "$ FullPath.tmp" $ FullPath
}
3. 文件菜单上,点击保存 。
4. 在 "另存为 "对话框中,找到你要保存PowerShell脚本的文件夹 。
5. 在文件名框中,输入FixFlacFiles.ps1,将保存类型框改为文本文档(*.txt),然后点击保存 。
6. 在Windows Explorer中,找到你保存的PowerShell脚本 。
7. 右键单击该脚本,然后单击用PowerShell运行 。
8. 当有提示时,输入无法播放的FLAC文件的文件名,然后按回车键 。

推荐阅读