KB5003430: FLAC-kodeeringuga muusikafail on rikutud metaandmete redigeerimisel Windows Exploreris

Rakenduskoht
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

Kokkuvõte

See värskendus lahendab metaandmete kodeerimise probleemi, mis põhjustab tasuta kaotsiminekuta helikodeki (FLAC) muusikafailide esitamise, kui nende pealkirja, esitajat või muid metaandmeid muudetakse.

Põhjus

See probleem võib ilmneda juhul, kui FLAC-failid sisaldavad FLAC-päise ees ID3-paneeli. ID3-paneel sisaldab metaandmeid (nt pealkiri ja esitaja). Atribuudi FLAC ohjur eeldas, et kõik FLAC-failid alustasid 4-baidilise alguskoodiga fLaC ega arvestanud faili alguses olevat ID3-kaadrit. Seetõttu kirjutatakse ID3 kaader üle ilma alguskoodi fLaC-ta, mis renderdab faili esitamatuks.

Lahendus

Selle probleemi vältimiseks edaspidiste FLAC-muusikafailide korral installige 25. mai 2021 – KB5003214 (operatsioonisüsteemi järgud 19041.1013, 19042.1013 ja 19043.1013) eelvaade.

Mõjutatud FLAC-muusikafailide parandamiseks käivitage järgmine PowerShelli skript.

NB!

See skript ei taasta ID3 paneelil talletatud kaotsiläinud metaandmeid. Siiski muudab see faili taasesitavaks.

  1. Avage Notepad.

  2. Kopeerige ja kleepige järgmine skript Notepadi:

    # Autoriõigus 2021, Microsoft
    # See skript parandab FLAC-faili, mis on Media Foundationi poolt rikutud viitega KB5003430.
    # Lisateavet leiate KB5003430
    param(
    [parameter(Mandatory=$true,
    HelpMessage="The path to the FLAC file that has been corrupted by Media Foundation",
    ValueFromRemainingArguments=$true)]
    [ValidteScript({ -not [String]::IsNullOrEmpty($_) -and (Test-Path $_) })]
    [String]$File
    )
    # Peame praeguse faili varundama, kui meil on tõrkeid
    $FileDirectory = Split-Path – lahenda $File
    $Filename = Split-Path -leht -Lahenda $File
    $FullPath = Join-Path – lahenda $FileDirectory $Filename
    $Filename = [String]::Format("Backup_{0:yyyyMMdd_hhmmss}_{1}", [KuupäevKõva]::Praegu, $Filename)
    $BackupLocation = Join-Path $FileDirectory $Filename
    Write-Output "Microsoft FLAC Repair Tool. See tööriist parandab FLAC-helifaili, mis oli üksikasjade redigeerimisel rikutud."
    Write-Output "Mõjutatud fail: $FullPath"
    Write-Output "Faili varundatakse: $BackupLocation"
    Write-Output "Kas soovite jätkata?"
    $choice=$host.ui.PromptForChoice("Flac-skripti parandamine", "Kas soovite jätkata", (&Jah, &Ei), 1)
    funktsioon ParseStreamInfoMetadataBlock([System.IO.FileStream]$stream)
    {
    $blockType = $stream. ReadByte()
    $lastBlock = ($blockType -shr 7) -ne 0
    $blockType = $blockType -band 0x7F
    if ($blockType -ne 0)
    {
    tagastus $false
    }
    $blockSize = (($stream. ReadByte() -shl 16) -bor ($stream. ReadByte() -shl 8) -bor $stream. ReadByte())
    if ($blockSize -lt 34)
    {
    tagastus $false
    }
    $minAudioBlockSize = ($stream. ReadByte() -shl 8) -bor $stream. ReadByte()
    $maxAudioBlockSize = ($stream. ReadByte() -shl 8) -bor $stream. ReadByte()
    if ($minAudioBlockSize -lt 16 -või $maxAudioBlockSize -lt 16)
    {
    tagastus $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 bait[] 16
    $stream. Read($MD 5HashBytes, 0, $MD 5HashBytes.Length)
    $MD 5Hash = [Guid]($MD 5HashBytes)
    if ($sampleRate -eq 0)
    {
    tagastus $false
    }
    # Nende kontrollide läbimine tähendab, et meil on tõenäoliselt voogesituse teabe päis ja saame faili uuesti luua
    Write-Output "Faili Stream teave"
    Write-Output "Valimi määr: $sampleRate"
    Write-Output "Helikanalid: $channelCount"
    Write-Output "Sample Depth: $bitsPerSample" (Näidissügavus: $bitsPerSample)
    Write-Output "MD5 helinäidise räsi: $MD 5Hash"
    tagastus $true
    }
    if ($choice -eq 0)
    {
    Copy-Item $FullPath – sihtkoha $BackupLocation – jõustamine
    $stream = [System.IO.File]::Open($FullPath, [System.IO.FileMode]::Open)
    $stream. Seek(4, [System.IO.SeekOrigin]::Begin)
    ($stream. ReadByte() -eq 0) {}
    # Nüüd peame välja selgitama, kust kehtiv FLAC metaandmete kaader algab
    # Tõenäoliselt osutame suuruse liikme viimasele baidile, seega otsime tagasi 4 baiti ja proovime uuesti
    $flacDataStartPosition = $stream. Asukoht – 4
    $stream. Seek($flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
    (-not(ParseStreamInfoMetadataBlock($stream)))
    {
    $flacDataStartPosition = $flacDataStartPosition + 1
    $stream. Seek($flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
    }
    # Sisestage alguskood
    $stream. Seek($flacDataStartPosition, [System.IO.SeekOrigin]::Begin)
    if (katsetee "$FullPath.tmp")
    {
    Remove-Item "$FullPath.tmp"
    }
    $fixedStream = [System.IO.File]::Open("$FullPath.tmp", [System.IO.FileMode]::CreateNew)
    [bait[]]$startCode = [char[]]('f', 'L', 'a', 'C');
    $fixedStream.Write($startCode; 0; $startCode.Length)
    $stream. CopyTo($fixedStream)
    $stream. Sule ()
    $fixedStream.Close()
    Move-Item – jõusta $FullPath.tmp $FullPath
    }
  3. Klõpsake menüü Fail käsku Salvesta.

  4. Otsige dialoogiboksis Nimega salvestamine üles kaust, kuhu soovite PowerShelli skripti salvestada.

  5. Tippige väljale Faili nimi tekstFixFlacFiles.ps1, muutke välja Salvestustüüp väljaks Tekstidokumendid (*.txt) ja seejärel klõpsake nuppu Salvesta.

  6. Otsige Windows Exploreris üles salvestatud PowerShelli skript.

  7. Paremklõpsake skripti ja seejärel klõpsake käsku Käivita PowerShelliga.

  8. Kui küsitakse, tippige esitamata FLAC-faili failinimi ja vajutage sisestusklahvi (Enter).