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類型?