使用 Microsoft 登入
登入或建立帳戶。
您好:
選取其他帳戶。
您有多個帳戶
選擇您要用來登入的帳戶。

摘要

此更新解決了中繼資料編碼問題,如果音樂檔案的標題、美工或其他中繼資料變更,則免費無遺失音訊編解碼器 (FLAC) 音樂檔案變得無法播放。 

原因

當 FLAC 檔案在 FLAC 標題之前包含 ID3 框架時,可能會發生此問題。 ID3 框架包含中繼資料,例如標題和美術師。 FLAC 屬性處理常式假設所有 FLAC 檔案都是以 4 位元組開始碼 fLaC 開頭,而且未考慮到檔案開頭的 ID3 框架。 因此,ID3 框架會先被覆蓋,而不會使用起始碼 fLaC,使檔案無法播放。

解決方案

若要防止日後 FLAC 音樂檔案發生此問題,請安裝 2021 年 5 月 25 日 -KB5003214 (OS 版本 19041.1013、19042.1013 和 19043.1013) Preview

若要修復受影響的 FLAC 音樂檔案,請執行下列 PowerShell 腳本。

重要: 此腳本不會還原儲存在 ID3 框架的遺失中繼資料。 不過,它確實可以再次播放檔案。

  1. 開啟 [記事本]。

  2. 複製並貼上下列腳本至記事本:

    # 著作權 2021 Microsoft

    # 此腳本會修復媒體基金會參照 KB5003430 時已損壞的 FLAC 檔案。

    # 請參閱 KB5003430 以瞭解更多資訊

    param (

    [parameter (Mandatory=$true,

    HelpMessage="MEDIA Foundation 已損壞 FLAC 檔案的路徑",

    ValueFromRemainingArguments=$true) ]

    [ValidateScript ({ -not [String]::IsNullOrEmpty ($_) -and (Test-Path $_) }) ]

    [String]$File

    )

    # 我們需要備份目前的檔案,避免發生任何錯誤

    $FileDirectory = Split-Path -解決$File

    $Filename = Split-Path -葉 -解決$File

    $FullPath = Join-Path -解決$FileDirectory $Filename

    $Filename = [String]::格式化 ("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

    如果 ($blockType -ne 0)

    {

    返回$false

    }

    $blockSize = ( ($stream。ReadByte () -shl 16) -bor ($stream。ReadByte () -shl 8) -bor $stream。ReadByte () )

    如果 ($blockSize -lt 34)

    {

    返回$false

    }

    $minAudioBlockSize = ($stream。ReadByte () -shl 8) -bor $stream。ReadByte ()

    $maxAudioBlockSize = ($stream。ReadByte () -shl 8) -bor $stream。ReadByte ()

    如果 ($minAudioBlockSize -lt 16 -或 $maxAudioBlockSize -lt 16)

    {

    返回$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位元組[] 16

    $stream。閱讀 ($MD 5HashBytes, 0, $MD 5HashBytes.length)

    $MD 5Hash = [Guid] ($MD 5HashBytes)

    如果 ($sampleRate -eq 0)

    {

    返回$false

    }

    # 通過這些檢查表示我們有資料流程資訊標題,可以重建檔案

    Write-Output「檔案串流資訊」

    Write-Output「樣本率:$sampleRate」

    Write-Output「音訊頻道:$channelCount」

    Write-Output「樣本深度:$bitsPerSample」

    Write-Output"MD5 音訊樣本雜湊:$MD 5Hash"

    返回$true

    }

    如果 ($choice -eq 0)

    {

    Copy-Item $FullPath -目的地$BackupLocation -Force

    $stream = [System.IO.File]::開啟 ($FullPath,[System.IO.FileMode]::開啟)

    $stream。請 (4,[System.IO.SeekOrigin]::)

    同時 ($stream。ReadByte () -eq 0) {}

    # 我們現在必須找出有效的 FLAC 中繼資料框架從哪裡開始

    # 我們可能會指向大小成員的最後一個位元組,因此我們會尋找 4 位元組,然後重試

    $flacDataStartPosition = $stream。位置 - 4

    $stream。尋找 ($flacDataStartPosition,[System.IO.SeekOrigin]::)

    而 ( 非 (ParseStreamInfoMetadataBlock ($stream) ) )

    {

    $flacDataStartPosition = $flacDataStartPosition + 1

    $stream。尋找 ($flacDataStartPosition,[System.IO.SeekOrigin]::)

    }

    # 插入開始程式碼

    $stream。尋找 ($flacDataStartPosition,[System.IO.SeekOrigin]::)

    如果 (Test-Path "$FullPath.tmp")

    {

    Remove-Item"$FullPath.tmp"

    }

    $fixedStream = [System.IO.File]::開啟 ("$FullPath.tmp",[System.IO.FileMode]::CreateNew)

    [byte[]]]$startCode = [char[]] ('f','L','a','C') ;

    $fixedStream.撰寫 ($startCode,0,$startCode。長度)

    $stream。CopyTo ($fixedStream)

    $stream。關閉 ()

    $fixedStream.關閉 ()

    Move-Item -Force "$FullPath.tmp" $FullPath

    }

  3. 在 [檔案」功能表上,按一下 [儲存。

  4. 在 [ 另存 新位值」 對話方塊中,找出要儲存 PowerShell 腳本的資料夾。

  5. 在 [檔案名FixFlacFiles.ps1,將 [另新FixFlacFiles.ps1方塊變更為 [文字檔 (*.txt) ,然後按一下[儲存

  6. 在 Windows中,找出您儲存的 PowerShell 腳本。

  7. 以滑鼠右鍵按一下腳本,然後按一下 [ 使用 PowerShell 執行>

  8. 當系統提示時,輸入無法播放 FLAC 檔案的檔案名,然後按Enter。

需要更多協助嗎?

想要其他選項嗎?

探索訂閱權益、瀏覽訓練課程、瞭解如何保護您的裝置等等。

社群可協助您詢問並回答問題、提供意見反應,以及聆聽來自具有豐富知識的專家意見。

這項資訊有幫助嗎?

您對語言品質的滿意度如何?
以下何者是您會在意的事項?
按下 [提交] 後,您的意見反應將用來改善 Microsoft 產品與服務。 您的 IT 管理員將能夠收集這些資料。 隱私權聲明。

感謝您的意見反應!

×