Reputation: 6817
is there any direct way of finding out whether file is an image or video while using ffmpeg library?
i know i can get codec_id from AVCodecContext (https://www.ffmpeg.org/doxygen/trunk/structAVCodecContext.html), but enumeration at https://www.ffmpeg.org/doxygen/trunk/group__lavc__core.html#gaadca229ad2c20e060a14fec08a5cc7ce
is really huge and doesnt seem to be categorized..
Upvotes: 1
Views: 2700
Reputation: 6817
ok after investigating ffprobe sources seems that i found something which helps (not sure if it's 100% reliable)
AVFormatContext->iformat->name
but similar problem there .. lot of uncategorized possibilities. except that it returns "image2"/"gif"/"ico" in case of an image. more image formats can appear, all supported are listed at http://www.ffmpeg.org/general.html#Image-Formats
if it's not an image, it is necessarry to analyze all streams and detect video stream within them (to know it's a video not an audio or subtitles file). basically check for:
AVFormatContext->streams[i]->codec->codec_type == AVMEDIA_TYPE_VIDEO
it is still necesarry to check iformat->name first, because streams check returns AVMEDIA_TYPE_VIDEO both for images and videos.
Upvotes: 2