[Flac-dev] Detecting FLAC file type

Martin Leese martin.leese at stanfordalumni.org
Tue Oct 6 12:57:56 PDT 2009


Shayne Wissler <wissler at gmail.com> wrote:

> I have a program that is given a random file and needs to determine
> whether it is Vorbis or FLAC. For Vorbis, there are various places
> where I can infer that I have a bad stream. But for FLAC, when I call
> either FLAC__stream_decoder_process_until_end_of_metadata or
> FLAC__stream_decoder_process_single, it searches the entire file
> before giving up. I'd like it to stop searching as soon as it loses
> sync, or find some better way to detect the file type without scanning
> the whole file. Any tips on the best way to do that?

Perhaps I have misunderstood your problem,
but is this not what magic numbers are for?

For Ogg Vorbis and Ogg FLAC, see:
http://wiki.xiph.org/index.php/MIMETypesCodecs#Codecs_Parameter

For Native FLAC, see:
http://flac.sourceforge.net/documentation_format_overview.html

Regards,
Martin
-- 
Martin J Leese
E-mail: martin.leese  stanfordalumni.org
Web: http://members.tripod.com/martin_leese/


More information about the Flac-dev mailing list