[Libav-user] Probing a file
Gonzalo Garramuno
ggarra13 at gmail.com
Thu Mar 13 00:55:28 CET 2014
I am wondering, in code, what's the most reliable way to probe a file to
see if ffmpeg will open it. I can open a context and see the return
value. However, this returns true for image formats like jpeg, png, and
others and I find those handled better with other libraries. Is there a
way to have ffmpeg test to open only video codecs with no image codecs.
Currently the hack I have is:
bool aviImage::test_filename( const char* buf )
{
AVFormatContext* ctx = NULL;
int error = avformat_open_input( &ctx, buf, NULL, NULL );
if ( ctx )
avformat_close_input( &ctx );
if ( error <= 0 ) return false;
return true;
}
The error <= 0 line is intentional instead of just error < 0. This hack
seems to avoid jpeg and others detection.
More information about the Libav-user
mailing list