概要
この更新プログラムは、タイトル、アーティスト、またはその他のメタデータが変更された場合に再生できない無料のロスレス オーディオ コーデック (FLAC) 音楽ファイルを引き起こすメタデータ エンコードの問題に対処します。
原因
この問題は、FLAC ファイルに、FLAC ヘッダーの前に ID3 フレームが含まれている場合に発生する可能性があります。 ID3 フレームには、タイトルやアーティストなどのメタデータが含まれています。 FLAC プロパティ ハンドラーは、すべての FLAC ファイルが 4 バイトの開始コード fLaC で開始され、ファイルの先頭にある ID3 フレームを考慮していないと想定しました。 したがって、ID3 フレームは、再生できないファイルをレンダリングする開始コード fLaC なしで上書きされます。
Resolution
今後の FLAC 音楽ファイルのこの問題を回避するには 、2021 年 5 月 25 日のKB5003214 (OS ビルド 19041.1013、19042.1013、19043.1013) プレビューをインストールします。
影響を受ける FLAC 音楽ファイルを修復するには、次の PowerShell スクリプトを実行します。
重要
このスクリプトは、ID3 フレームに格納された失われたメタデータを復元しません。 ただし、ファイルを再び再生できるようになります。
メモ帳を開きます。
次のスクリプトをメモ帳にコピーして貼り付けます。
# Copyright 2021 Microsoft
# このスクリプトは、KB5003430を参照して Media Foundation によって破損した FLAC ファイルを修復します。
# 詳細については、KB5003430を参照してください
param(
[parameter(Mandatory=$true,
HelpMessage="Media Foundation によって破損した FLAC ファイルへのパス",
ValueFromRemainingArguments=$true)]
[ValidateScript({ -not [String]::IsNullOrEmpty($_) -and (Test-Path $_) })]
[String]$File
)
#エラーが発生した場合は、現在のファイルをバックアップする必要があります
$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 修復ツール。 このツールは、その詳細を編集するときに破損したFLACオーディオファイルを修復します。
Write-Output "影響を受けるファイル: $FullPath"
Write-Output "ファイルのバックアップが作成されます: $BackupLocation"
Write-Output 「続行しますか?
$choice=$host.ui.PromptForChoice("固定FLACスクリプト", "続行しますか", ('&はい', '&いいえ'), 1)
関数 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
$MD 5HashBytes = New-Object byte[] 16
$stream。Read($MD 5HashBytes, 0, $MD 5HashBytes.Length)
$MD 5Hash = [Guid]($MD 5HashBytes)
if ($sampleRate -eq 0)
{
return $false
}
# これらのチェックに合格すると、ストリーム情報ヘッダーがあり、ファイルを再構築できる可能性が高くなります
Write-Output "ファイルStream情報"
Write-Output "サンプル レート: $sampleRate"
Write-Output "オーディオ チャネル: $channelCount"
Write-Output "サンプルの深さ: $bitsPerSample"
Write-Output "MD5 Audio Sample Hash: $MD 5Hash"
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) {}
# ここで、有効な FLAC メタデータ フレームがどこから始まるかを把握する必要があります
# サイズ メンバーの最後のバイトを指している可能性が高いので、4 バイトをシークして再試行します
$flacDataStartPosition = $stream。位置 - 4
$stream。Seek($flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
while (-not(ParseStreamInfoMetadataBlock($stream)))
{
$flacDataStartPosition = $flacDataStartPosition + 1
$stream。Seek($flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
}
# 開始コードを挿入する
$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
}[ファイル] メニューの [保存] をクリックします。
[ 名前を付けて保存 ] ダイアログ ボックスで、PowerShell スクリプトを保存するフォルダーを見つけます。
[ ファイル名 ] ボックスに 「FixFlacFiles.ps1」と入力し、[ 名前を付けて保存] ボックス を [テキスト ドキュメント (* .txt)] に変更し、[ 保存] をクリックします。
Windows エクスプローラーで、保存した PowerShell スクリプトを見つけます。
スクリプトを右クリックし、[ PowerShell で実行] をクリックします。
メッセージが表示されたら、再生できない FLAC ファイルのファイル名を入力し、 Enter キーを押します。