Kaydol

Flood göndermek, insanların floodlarını okumak ve diğer insanlarla bağlantı kurmak için sosyal Floodlar ve Flood Yanıtları Motorumuza kaydolun.

Oturum aç

Flood göndermek, insanların floodlarını okumak ve diğer insanlarla bağlantı kurmak için sosyal Floodlar ve Flood Yanıtları Motorumuza giriş yapın.

Şifremi hatırlamıyorum

Şifreni mi unuttun? Lütfen e-mail adresinizi giriniz. Bir bağlantı alacaksınız ve e-posta yoluyla yeni bir şifre oluşturacaksınız.

3 ve kadim dostu 1 olan sj'yi rakamla giriniz. ( 31 )

Üzgünüz, Flood yazma yetkiniz yok, Flood girmek için giriş yapmalısınız.

Lütfen bu Floodun neden bildirilmesi gerektiğini düşündüğünüzü kısaca açıklayın.

Lütfen bu cevabın neden bildirilmesi gerektiğini kısaca açıklayın.

Please briefly explain why you feel this user should be reported.

Update: Windows 10 Corrupted .wav files (Now fixed!)

tl;dr: I fixed it! But this is also a tale of why you should always have backups. If you are interested in the code that fixes the files, it’s [here](https://github.com/ricka/fixwav).

# Back story

This is an update to [this](https://www.reddit.com/r/DataHoarder/comments/de4h6n/windows_10_corrupted_wav_files/) thread from 2 years ago. This might not be the exact right sub for this post, but this community helped me fix the issue so I wanted to say thanks and describe how I fixed it. I haven’t been working on this the entire time…it just sat on my todo list for a while and I wanted to try to fix this as a Christmas gift.

Basically, it looks like some process half tried to add id3 tags to the wav files, but broke the wav header in the process leaving the files unplayable by any media player I tried. My in-law was told that this was part of the Windows Update process that he got a computer store to do, but I’m half wondering if that store didn’t try to rip all his music and botch it up in the process as I’ve found no other mention of Windows Update processes doing this.

# Tech Details

Basic wav files have a structure as defined [here](http://soundfile.sapp.org/doc/WaveFormat/). You’ll note that there is nothing in that spec about metadata (tags). Additionally though, wav files are a subset of the RIFF format, which supports “INFO” tags, more details can be found [here](https://www.robotplanet.dk/audio/wav_meta_data/). That article makes it seem like the INFO tags are straightforward, but they are not. Some tools put INFO at the beginning of the file before the fmt/data headers in the wav section, some put it after, and some ignore it.

I mention all of this to help dissuade anyone from continuing to use wav for audio. I would personally recommend flac as it is loseless and compressed, but if you are paranoid about the compression, AIFF is uncompressed and supports metadata more rigidly. wav as a format is broken for trying to keep metadata in the file. PLEASE STOP USING WAV FILES.

To understand the corruption, you kind of need to see it pointed out side by side. Here’s a view of an uncorrupted wav file:

https://preview.redd.it/ysaxqpcfyc081.png?width=1837&format=png&auto=webp&s=70884132d38c18420b14eee8ab85a8ba4671f642

And here’s a corrupted wav file:

https://preview.redd.it/w7n9y2imyc081.png?width=1837&format=png&auto=webp&s=dc65da19fee28854e4b9fd05a24d115bc24b8842

Once I saw that this pattern was pretty consistent, I still had to read the specs on LIST/INFO tags (little endian, signed int) as well as [ID3 tags](https://id3.org/id3v2.3.0) (big endian, signed int) to do the math to rewrite the headers appropriately. It might not be obvious if you haven’t seen this before, but the headers contain info just after them about how long each header is. I used python to check if the wave file was corrupt with the wave standard library, and if so I would parse the RIFF header up to the ID3 tags (to keep total length), remove the ID3 headers, add in a standard wav header, calculate total length of the file with data, and update the length headers appropriately. In case that code is helpful to anyone, I’ve shared it [here](https://github.com/ricka/fixwav).

One last thing is that there definitely was at least some data loss, as some of the data sections of the wav files had an odd number of bytes. This is nonstandard and causes the wav to play terribly, so I choose to pad data that had an odd number of bytes with a 0 byte upfront. I’m not sure if this is the best solution, but it worked. Once I applied that fix to the code and processed everything, all files play normally!

# Summary

Always, always, ALWAYS have a backup of everything you care about before having your PC/laptop/whatever worked on. I’m probably preaching to the choir here, but I learned way more than I ever cared to about wav files and tagging just to fix this mess, and I flat out got lucky. Most corruption isn’t this simple or consistent when it happens, so have your backups at the ready before getting any type of maintenance done on your tech.

Benzer Yazılar

Yorum eklemek için giriş yapmalısınız.

5 Yorumları

  1. >My in-law was told that this was part of the Windows Update process that he got a computer store to do, but I’m half wondering if that store didn’t try to rip all his music and botch it up in the process as I’ve found no other mention of Windows Update processes doing this.

    That’s why you never send in your machines for repair with the drives in it. Also, the reason I’ll never buy a laptop that I can’t take apart without losing the warranty

  2. LOL, can’t believe this was 2 years ago, but that’s par for miscellaneous coding side projects.

    Nicely done, though I hate that this kind of content sits on Reddit. It used to be much easier to find content with this sort of technical depth on the old web, but here, it’s basically doomed to be lost eventually.

  3. This is an excellent post! As a fellow Music Hoarder I appreciate this greatly!

    Its also always good to hear stories of why things should be backed up! The moment things fail is the ‘coulda woulda shoulda’ moment!!

    PS: I did not know this about AIFF files! Now you have sent me on a hunt to swap out my .FLAC for AIFF <3

  4. Thank you for sharing! You said you’d recommend flac or aiff, but what about good old mp3?

  5. i’d have just reripped/redownloaded wwhatever was corrupt and been done with it…2 years…ugh