Windows操作系统|Win10竟会损坏用户文件!教你解决这个Bug
如果你是一名音乐发烧友,那么应该知道Flac这种常见的无损音乐格式 。Flac音乐文件支持metadata,用户可以编辑metadata,让音乐文件带有艺术家、所属专辑、音轨等等信息 。
通常来说,metadata和音频数据并不相关,修改metadata并不会影响音频本身 。
但是,近日微软官方公布了Win10中存在一个Bug,在Win10中用资源管理器修改Flac文件的metadata,竟会导致音频的损坏!
文章图片
根据Windows Latest的报道,微软最新发布的一份支持文件披露,如果在Win10的2004或者更高版本中,使用文件资源管理器修改Flac音乐文件的metadata,就会损耗Flac音频文件 。
这个Bug在Win10专业版、家庭版、企业版、工作站版乃至其他版本的Win10中均有出现 。
根据微软本月早些时候发布的支持文件,Win10的文件资源管理器导致了这个错误,它破坏了Flac文件头包含的ID3框架也就是metadata,而这个ID3框架负责存储音频的注释,例如音乐标题、艺术家、专辑、曲目编号等 。
在Win10上,Flac的处理程序忽视了ID3框架,该程序认为Flac文件在使用4字节的文件头,当Flac文件被Win10编辑的时候,ID3框架被覆盖了,导致没有了开始代码,导致了音乐播放器无法识别被修改后的文件 。
因此,在Win10中,如果你直接用文件资源管理器修改Flac音乐文件的标题、艺术家等metadata,会导致该文件无法播放 。
幸运的是,微软已经确定了Bug的根本原因,用户可以通过Windows Update升级KB5003214补丁进行修复 。
在KB5003214补丁中,微软确认了上文提到的错误已经被修复,修改了Flac的标题、艺术家等metadata后,Flac不会再变得无法播放 。
而对于已经损坏了的Flac文件,微软则发布了一个PowerShell脚本来进行修复,运行该脚本后Flac文件即可重新播放,不过已经从ID3框架中丢失了的metadata信息并不能恢复 。
下面是利用PowerShell脚本修复Flac文件的具体方法 。
1、开启记事本;
2、复制以下字符,粘贴到记事本中:
# Copyright 2021 Microsoft
# This script will repair a FLAC file that has been corrupted by Media Foundation in reference to KB5003430.
# Refer to KB5003430 for further information
param(
[parameter(Mandatory=$true,
HelpMessage="The path to the FLAC file that has been corrupted by Media Foundation",
ValueFromRemainingArguments=$true)]
[ValidateScript({ -not [String]::IsNullOrEmpty($_) -and (Test-Path $_) })]
[String]$File
)
# We need to back up the current file incase we have any errors
$FileDirectory = Split-Path -Resolve $File
$Filename = Split-Path -Leaf -Resolve $File
$FullPath = Join-Path -Resolve $FileDirectory $Filename
$Filename = [String]::Format("Backup_{0:yyyyMMdd_hhmmss}_{1}", [DateTime]::Now, $Filename)
$BackupLocation = Join-Path $FileDirectory $Filename
Write-Output "Microsoft FLAC Repair Tool. This tool will repair a FLAC audio file that was corrupted when editing its details."
Write-Output "Affected File: $FullPath"
Write-Output "A backup of the file will be made: $BackupLocation"
Write-Output "Do you wish to continue?"
$choice=$host.ui.PromptForChoice("Fixing FLAC Script", "Do you wish to continue", ('&Yes', '&No'), 1)
function ParseStreamInfoMetadataBlock([System.IO.FileStream]$stream)
{
$blockType = $stream.ReadByte()
$lastBlock = ($blockType -shr 7) -ne 0
$blockType = $blockType -band 0x7F
if ($blockType -ne 0)
{
return $false
}
$blockSize = (($stream.ReadByte() -shl 16) -bor ($stream.ReadByte() -shl 8) -bor $stream.ReadByte())
if ($blockSize -lt 34)
{
return $false
}
$minAudioBlockSize = ($stream.ReadByte() -shl 8) -bor $stream.ReadByte()
$maxAudioBlockSize = ($stream.ReadByte() -shl 8) -bor $stream.ReadByte()
if ($minAudioBlockSize -lt 16 -or $maxAudioBlockSize -lt 16)
{
return $false
}
$minFrameSize = (($stream.ReadByte() -shl 16) -bor ($stream.ReadByte() -shl 8) -bor $stream.ReadByte())
$maxFrameSize = (($stream.ReadByte() -shl 16) -bor ($stream.ReadByte() -shl 8) -bor $stream.ReadByte())
$sampleInfo = (($stream.ReadByte() -shl 24) -bor ($stream.ReadByte() -shl 16) -bor ($stream.ReadByte() -shl 8) -bor $stream.ReadByte())
$sampleRate = $sampleInfo -shr 12
$channelCount = (($sampleInfo -shr 9) -band 0x7) + 1
$bitsPerSample = (($sampleInfo -shr 4) -band 0x1F) + 1
[UInt64]$sampleCount = (($stream.ReadByte() -shl 24) -bor ($stream.ReadByte() -shl 16) -bor ($stream.ReadByte() -shl 8) -bor $stream.ReadByte())
$sampleCount = (([UInt64]$sampleInfo -band 0xF) -shl 32) -bor $sampleCount
推荐阅读
- 操作系统|6年来首次更新 FreeDos系统新版下载:仅需20MB
- 微软|真正从头开始 消息称微软Windows 12系统与Win10/11大不同
- Windows操作系统|性能提升4倍 内存占用率暴降!Win11改进细节:UI响应速度最高提升76%
- 微软|新Windows就要来了!曝微软计划开展Win12开发工作
- Windows操作系统|实用经典功能回归!Win11文件管理器迎来大改
- Windows操作系统|不符合条件Win10设备升Win11:微软这手段着实不爽 在桌面打水印
- Windows|Windows 11加入多项新功能:“快速访问”能固定文件了
- 微软|Windows 11的某些功能 可能永远不会成真
- 联想|打通Windows与安卓壁垒!联想拯救者手机/平板/PC将支持“超级互联”
- Windows操作系统|性能提升4倍:内存占用率暴降!Windows 11大改进不杀进程
