embedded audio in a gif
May 5, 2005 6:21 AM   Subscribe

So, on Waxy links today, I found this gif file, which, when loaded in Winamp, plays a brief, irritating song. How's that happen? When I load it into Windows Media Player, it displays as an animated gif. One file type, multiple properties. Can anyone elaborate on what's happening here?
posted by jonson to Computers & Internet (11 answers total)
 
It seems that there's a stream associated with the file. Interesting. I'd like to know how they do this too.
posted by ashbury at 7:22 AM on May 5, 2005


Best answer: It's a GIF file with an MP3 file tacked on to the end. Most MP3 players are pretty forgiving and made to skip any unknown data at the beginning or end of the file (that's where the tags are) until it gets to valid MP3 data. In the case of the web browser, when it loads the file, it recognizes and decodes the GIF data at the beginning and throws away the rest. I just made my own.
posted by zsazsa at 7:32 AM on May 5, 2005


So how do you "tack it on"?
posted by 31d1 at 8:01 AM on May 5, 2005


I'm assuming something like

$ cat file.mp3 >> file.gif
posted by angry modem at 8:09 AM on May 5, 2005


yep, I did exactly what angry modem said. That works in Unixy operating systems (MacOS, Linux), and there are lots of ports of the "cat" program to Windows, too.
posted by zsazsa at 8:23 AM on May 5, 2005


There are two tiny facts about GIF files and ZIP files you might like to know about: GIF files have their length defined at the start of the file; any bytes after are ignored. ZIP files have a table at the end; anything at the start of the file is ignored. The result is that a file can be both a GIF and a ZIP, just change the extension.

--Steganography for DeCSS [picture]

Presumably, MP3 works the same way?
posted by chota at 9:02 AM on May 5, 2005


while i think this is a pretty awesome trick, it saddens me that you labeled this classic dr. mario song as annoying.
posted by lotsofno at 10:50 AM on May 5, 2005


copy /b file.gif + file.mp3 my_new_annoying_file.gif

The /b is important. :-)
posted by shepd at 11:38 AM on May 5, 2005


chota: good guess (and interesting link), but in the case of mp3 it's different. The mpeg-audio format was designed for streaming type uses (digital radio or satellite or whatever) where there might be bursts of bad data or dropped data. So each audio frame is preceded by a recognizable pattern (sync marker), and mp3 players are usually written to silently skip over blocks of unrecognized data until they see some valid sync markers. In this case, the unrecognized data happens to be a valid GIF image.

This is how id3 tags are inserted, also: there's no real support for them in the mp3 format, but since the players are pretty tolerant of random garbage showing up in the middle of their files, you can stuff the track name / artist / etc. info in there without really disturbing anything.
posted by hattifattener at 4:03 PM on May 5, 2005


Sure, I've always preferred Fever to Chill, but still, annoying song? For shame.
posted by cosmonaught at 5:45 PM on May 5, 2005


Response by poster: I would like to take this time to thank the several bright & helpful people who answered, and to formally apologize to lotsofno, cosmonaught & dr mario himself for my too harsh judgement of the theme from dr mario.
posted by jonson at 9:46 PM on May 5, 2005


« Older Morocco   |   Good DVD-only recorder? Newer »
This thread is closed to new comments.