首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >libavformat:在C++中获取格式

libavformat:在C++中获取格式
EN

Stack Overflow用户
提问于 2017-08-09 11:30:21
回答 1查看 943关注 0票数 0

我在一个运行在Arch上的C++应用程序上工作,它应该使用libavformat来获得一个媒体文件mime类型。目前使用的行如下:

代码语言:javascript
复制
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字符串“视频/x-matroska,.”。但是对于任何其他文件格式,如*.mp4或*.avi,iformat->mime_type将始终返回NULL。

如何获得其他容器格式的Mime类型?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-09 15:52:30

似乎avformat_find_stream_info只设置了iformat,并且大多数AVInputFormat变量没有初始化mime_type字段。

您也可以使用

代码语言:javascript
复制
AVOutputFormat* format = av_guess_format(NULL,path.c_str(),NULL);
if(format)
  printf("%s\n",format->mime_type);
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45589437

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档