首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用libav解析VP8比特流

如何用libav解析VP8比特流
EN

Stack Overflow用户
提问于 2014-07-25 02:46:11
回答 1查看 1.1K关注 0票数 0

我刚刚开始了解VP8,所以如果这是一个愚蠢的问题,请给我一些放松。

H.264示例

在过去,我主要从事H.264的工作。每当我需要解析H.264比特流时,我都会利用libav来帮助我并使用类似的东西

代码语言:javascript
复制
av_register_all();

_ioContext = avio_alloc_context(
        encodedData,
        H264_READER_BUF_SIZE,
        0,
        0,
        &readFunction,
        NULL,
        NULL);
if (_ioContext == NULL)
    throw std::exception("Unable to create AV IO Context");

AVInputFormat *h264Format = av_find_input_format("h264");
if (h264Format == NULL) {
    throw std::exception("Unable to find H264 Format");
}

_context = avformat_alloc_context();
_context->pb = _ioContext;

ret = avformat_open_input(&_context,
        "",
        h264Format,
        NULL);

if (ret != 0) {
    throw std::exception(
            "Failed to open input file :" +
            std::string(_avErrToString(ret)));
}

VP8

上述方法在解析H.264比特流和为我提供H.264帧以提供给我自己的解码基础结构方面发挥了很大的作用。

我正试图在VP8中重复同样的工作。我尝试使用这段代码作为基础,而不是寻找"h264“格式,而是尝试了"vp8”和"webm“。"vp8“似乎无效,但"webm”能够加载格式。然而,当我到达avformat_open_input时,我会得到以下错误:

matroska,webm @ 0x101812400未知条目0xF0 使用不受支持的特性的matroska,webm @ 0x101812400 EBML报头 (EBML版本0,doctype (null),doc版本0) 未能打开输入文件:尚未在FFmpeg中实现,欢迎修补程序

我看不见了吗?还是我只是不正确地接近这个?

EN

回答 1

Stack Overflow用户

发布于 2014-08-22 21:15:38

我将 C#包装器用于FFMPEG\LibAV (特别是示例文件),它具有与C++示例文件相同的语法,并且工作正常。

错误消息说它还没有实现,所以我建议更新您的libav库。

正在工作的代码(包括我对AVInputFormat的修改,它在链接的示例文件中不存在):

代码语言:javascript
复制
FFmpegInvoke.av_register_all();
FFmpegInvoke.avcodec_register_all();
FFmpegInvoke.avformat_network_init();

string url = @"C:\file.webm";

AVFormatContext* pFormatContext = FFmpegInvoke.avformat_alloc_context();

AVInputFormat* pFormatExt = FFmpegInvoke.av_find_input_format("webm");

if (FFmpegInvoke.avformat_open_input(&pFormatContext, url, pFormatExt, null) != 0)
    throw new Exception("Could not open file"); //no exception is thrown

//more code to decode frames, and frames are decoded successfully

如果这样做不起作用,那么可能您打开的文件不正确( avformat_open_input的第二个参数为空)。

也许试着指定一个文件路径?

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24947246

复制
相关文章

相似问题

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