KB5003430: il file musicale codificato in FLAC viene danneggiato quando i metadati vengono modificati in Esplora risorse

Si applica a
Windows 10 Enterprise, version 2004 Windows 10 Home and Pro, version 2004 Windows 10 Pro, version 2004 Windows 10 Enterprise and Education, version 2004 Windows 10 Pro Education, version 2004 Windows 10 Pro for Workstations, version 2004 Windows 10 Pro, version 20H2 Windows 10 Enterprise, version 20H2 Windows 10 Enterprise and Education, version 20H2 Windows 10 Home and Pro, version 20H2 Windows 10 Pro Education, version 20H2 Windows 10 Pro for Workstations, version 20H2

Riepilogo

Questo aggiornamento risolve un problema di codifica dei metadati che rende i file musicali Free Lossless Audio Codec (FLAC) non riproducibili se il titolo, l'artista o altri metadati vengono modificati.

Causa

Questo problema può verificarsi quando i file FLAC contengono un frame ID3 prima dell'intestazione FLAC. La cornice ID3 contiene metadati come il titolo e l'artista. Il gestore delle proprietà FLAC presupponeva che tutti i file FLAC iniziassero con il codice di avvio a 4 byte fLaC e non tenessero conto del frame ID3 all'inizio del file. Pertanto, il frame ID3 verrebbe sovrascritto senza che il codice di avvio fLaC renda il file non riproducibile.

Risoluzione

Per evitare questo problema per i futuri file musicali FLAC, installa il 25 maggio 2021 - KB5003214 (build del sistema operativo 19041.1013, 19042.1013 e 19043.1013) Anteprima.

Per ripristinare i file musicali FLAC interessati, esegui il seguente script PowerShell.

Importante

Questo script non ripristinerà i metadati persi archiviati nel frame ID3. Tuttavia, rende il file nuovamente riproducibile.

  1. Aprire il Blocco note.

  2. Copiare e incollare lo script seguente in Blocco note:

    # Copyright 2021 Microsoft
    # Questo script ripristinerà un file FLAC danneggiato da Media Foundation in riferimento a KB5003430.
    # Per ulteriori informazioni, fare riferimento a KB5003430
    param(
    [parametro(Mandatory=$true,
    HelpMessage="Il percorso del file FLAC che è stato danneggiato da Media Foundation",
    ValueFromRemainingArguments=$true)]
    [ValidateScript({ -not [String]::IsNullOrEmpty($_) -and (Test-Path $_) })]
    [stringa]$File
    )
    # Dobbiamo eseguire il backup del file corrente in caso di errori
    $FileDirectory = Split-Path -Resolve $File
    $Filename = Split-Path -leaf -resolve $File
    $FullPath = Join-Path -Resolve $FileDirectory $Filename
    $Filename = [stringa]::formato("Backup_{0:yyyyMMdd_hhmmss}_{1}", [DateTime]::Now, $Filename)
    $BackupLocation = Join-Path $FileDirectory $Filename
    Write-Output "Strumento di riparazione Microsoft FLAC. Questo strumento ripristinerà un file audio FLAC danneggiato durante la modifica dei dettagli."
    Write-Output "File interessato: $FullPath"
    Write-Output "Verrà eseguito un backup del file: $BackupLocation"
    Write-Output "Vuoi continuare?"
    $choice=$host.ui.PromptForChoice("Correzione dello script FLAC", "Vuoi continuare", ('&Sì', '&No'), 1)
    funzione ParseStreamInfoMetadataBlock([System.IO.FileStream]$stream)
    {
    $blockType = $stream. ReadByte()
    $lastBlock = ($blockType -shr 7) -ne 0
    $blockType = $blockType -band 0x7F
    if ($blockType -ne 0)
    {
    restituire $false
    }
    $blockSize = (($stream. ReadByte() -shl 16) -bor ($stream. ReadByte() -shl 8) -bor $stream. ReadByte())
    IF ($blockSize -LT 34)
    {
    restituire $false
    }
    $minAudioBlockSize = ($stream. ReadByte() -shl 8) -bor $stream. ReadByte()
    $maxAudioBlockSize = ($stream. ReadByte() -shl 8) -bor $stream. ReadByte()
    se ($minAudioBlockSize -lt 16 -o $maxAudioBlockSize -lt 16)
    {
    restituire $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)
    se ($sampleRate -EQ 0)
    {
    restituire $false
    }
    # Il superamento di questi controlli significa che probabilmente abbiamo un'intestazione di informazioni sul flusso e possiamo ricostruire il file
    Write-Output "Informazioni Stream file"
    Write-Output "Frequenza di campionamento: $sampleRate"
    Write-Output "Canali audio: $channelCount"
    Write-Output "Profondità campione: $bitsPerSample"
    Write-Output "MD5 Audio Sample Hash: $MD 5Hash"
    restituire $true
    }
    se ($choice -eq 0)
    {
    Copy-Item $FullPath -Destinazione $BackupLocation -Forza
    $stream = [System.IO.File]::Open($FullPath, [System.IO.FileMode]::Open)
    $stream. Seek(4, [System.IO.SeekOrigin]::Begin)
    mentre ($stream. ReadByte() -eq 0) {}
    # Ora dobbiamo capire dove inizia un frame di metadati FLAC valido
    # È probabile che si stia puntando all'ultimo byte del membro di dimensione, quindi si cercheranno 4 byte e si riproverà
    $flacDataStartPosition = $stream. Posizione - 4
    $stream. Seek($flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
    while (-not(ParseStreamInfoMetadataBlock($stream)))
    {
    $flacDataStartPosition = $flacDataStartPosition + 1
    $stream. Seek($flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
    }
    # Inserire il codice di avvio
    $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. Chiudi()
    $fixedStream.Close()
    Move-Item - Forza "$FullPath.tmp" $FullPath
    }
  3. Scegliere Salva dal menu File.

  4. Nella finestra di dialogo Salva con nome individuare la cartella in cui si vuole salvare lo script di PowerShell.

  5. Nella casella Nome file , digitare FixFlacFiles.ps1, modificare la casella Tipo file in Documenti di testo (*.txt) e quindi fare clic su Salva.

  6. In Esplora risorse individuare lo script di PowerShell salvato.

  7. Fare clic con il pulsante destro del mouse sullo script e quindi scegliere Esegui con PowerShell.

  8. Quando richiesto, digita il nome del file FLAC non riproducibile e quindi premi INVIO.