[ogg-dev] Fixing ogg vorbis corruption caused by bad metadata

Adam Rosi-Kessel adam at rosi-kessel.org
Thu Jul 16 06:33:29 PDT 2009


Adam Rosi-Kessel wrote, on 7/15/2009 8:03 PM:
> Erik de Castro Lopo wrote, on 7/15/2009 7:39 PM:
>>> Yes, it was Mediamonkey. They claim that it was due to a bug in vorbis
>>> libraries.
>> All software has bugs, but this explanation doesn't really add up.
>> libvorbis is the codec. If they had blamed libogg, which does the
>> container, then yes, that would have been a believable explanation :-).
>
> Actually, they are technically pointing at both ogg and vorbis:
>
> http://www.ventismedia.com/mantis/view.php?id=5809

I've been pushing the Mediamonkey support people to explain what the 
precise bug was, but just get pointed back to this URL, which identifies 
ogg_static and vorbis_static.

Meanwhile, I'm coming close to a workable bulk method for restoring the 
files. Here's the shorter version:

- Extract all metadata from the corrupted file by scraping for strings 
(ALBUM=album_name, etc.)

- Extract the vorbis setup header from the corrupted file -- everything 
between \003vorbis and the end of the packet

- Drop all packets from the corrupted file with granulepos 0

- Add first three packets from a good file

- Replace vorbis setup header in the good file with the one extracted 
from the corrupted file

- Recalculate CRCs

- Search/replace serial numbers

- Add extracted metadata back in

This method seems to work on any file so long as the setup header is 
still intact. It doesn't seem like it would be difficult to generalize 
this into a broad ogg/vorbis repair tool -- extract whatever valid data 
you find from the first three packets, and then rewrite a valid header 
with that information. Seems like it would be a useful tool.

Adam


More information about the ogg-dev mailing list