0
我使用在Arch Linux上运行的应用libavformat获取媒体文件MIME类型的C++应用程序。目前使用以下行:libavformat:获取格式Mime在C++中输入
std::string path = "/path/to/file.extension";
av_register_all();
AVFormatContext* pFormatCtx = avformat_alloc_context();
avformat_open_input(&pFormatCtx, path.c_str(), NULL, NULL);
avformat_find_stream_info(pFormatCtx, NULL);
std::string mimeType(pFormatCtx->iformat->mime_type);
现在,这将符合预期与* .mkv(Matroska)文件。返回预期的逗号分隔的mimeType字符串“video/x-matroska,...”。但是对于任何其他文件格式,如* .mp4或* .avi,iformat-> mime_type将始终返回NULL。
如何获取其他容器格式的MIME类型?