【发布时间】:2018-01-17 06:28:57
【问题描述】:
我在 Arch Linux 上运行的 C++ 应用程序工作,它应该使用 libavformat 来获取媒体文件 mime 类型。目前使用以下几行:
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 类型?
【问题讨论】:
标签: c++ ffmpeg mime-types libav libavformat