Reputation: 689
I'm testing a C++ program that should iterate in a directory and find all multimedia files. I used an iteration routine, and for every file I tried using the libav functions to open the file, such as av_find_stream_info
in order to find stream info. It works fine for multimedia files, such as video and images, but the problem is that it recognizes some files as audio or video, for example it sees an audio stream inside a .o file! I also tried to use av_read_frame
and it worked fine, without errors! I would like to avoid filtering by extension, is there any other solution to find "playable" files?
Thanks
Upvotes: 0
Views: 312
Reputation: 182829
This is a dark art. You have to rule out certain commonly-seen file types that can masquerade as media files. You want a package that has already done all the work for you, and that is the file
package and its libmagic
component. (Your platform may already have it. If it's UNIXy, try man 3 libmagic
or see if you have a file-devel
package.)
Upvotes: 1