[ogg-dev] Appending at the end of the file

Ralph Giles giles at xiph.org
Sun Oct 22 07:15:56 PDT 2006

On Sun, Oct 22, 2006 at 02:49:07AM +0200, A.David David wrote:

> Hi all, I am trying to append some image to my ogg file
> but it results to corruption of the file, as there is no real way of
> including images
> in the OGG, I just tried to append the image at the end.

Yes, that will look like corruption to any reader.

The spec-compliant way to do this is to put the image in a separate ogg 
stream and multiplex it with the audio. See http://wiki.xiph.org/OggMNG 
for how to do this with PNG and jpeg images. Unfortunately, vorbisfile
based audio player won't play such files. This is a limitation of 

You can also abuse the comment header for this. Just add a comment like 
"COVERART=<binary image blob>". The vorbis_commen_*() api discourages
this by only letting you pass C strings, so you'd have to manipulate the 
vorbis_comment struct directly.

Finally, if it's just album cover art, you might consider: put each 
album in a separate directory, with the cover art, etc. as separate 
files next to the audio. If you're on a unix-like os, then you can use 
something like the .directory metadata file from the freedesktop.org 
Desktop Entry Specification to point to the album art and it will show 
up in some players as well as the file browser.


More information about the ogg-dev mailing list