如何使用的Qt4 libav codeC? [英] How to use libavcodec in Qt4?

查看:206
本文介绍了如何使用的Qt4 libav codeC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用libav codeC在Qt4的访问单个视频帧?

How do I use libavcodec in Qt4 to access individual video frames?

验证该视频流可以通过libav $ C $立方厘米德$ C $光盘通过编译<经过href=\"http://web.me.com/dhoerl/Home/Tech_Blog/Entries/2009/1/22_Revised_av$c$cc_sample.c_files/av$c$cc_sample.0.5.0.c\"相对=nofollow>这个例子,我搬到源$ C ​​$ C到我的C ++程序。现在 av_open_input_file()突然无法打开我的视频文件。(返回错误code:-2)

After verifying that the video stream can be decoded by libavcodec by compiling this example, I moved the source code to my C++ program. Now av_open_input_file() is suddenly unable to open my video file (returning an errorcode: -2).

调用看起来像这样现在:

The call looks like this right now:

...
// Register all formats and codecs
avcodec_register_all();

// Open video file
QString videoFileName("/absolute/path/to/video.avi"); // from somewhere else in the application
const char* fileName = videoFileName.toStdString().c_str();
int err = 0;
if((err = av_open_input_file(&pFormatCtx, fileName, NULL, 0, NULL)) != 0)
{
    doErrorHandling(err, fileName); // err = -2
}

当我在看为const char *文件名在调试器中它看起来是正确的。我在做一些基本的错误在混合C和C ++ code(我刚刚从倾倒的例子中,code到一个类的构造函数第一次尝试)?

When I look at const char* fileName inside the debugger it looks correct. Am I making some basic mistake in mixing C and C++ code (for a first attempt I just dumped the code from the example into the constructor of a class)?

注意:为了获取应用程序编译包括我这样的标题:

Note: In order to get the application to compile I include the headers like this:

extern "C"
{
#define __STDC_CONSTANT_MACROS // for UINT64_C
#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>
#include <libswscale/swscale.h>
}

我也试图硬code的路径,视频文件到应用程序中没有任何成功:

I have also tried to hard code the path to the video file into the application without any success:

av_open_input_file(&pFormatCtx, "/home/bjoernz/video.avi", NULL, 0, NULL);

我是能够编译和执行使用的例子(AV codec_sample.0.5.0.c) G ++

推荐答案

那么,这是尴尬的:

当我转移从这个例子给C ++应用程序我犯了一个愚蠢的错误,当我链接错误,这对我的源$ C ​​$ C,它 av_register_all(); 不可用......我它重命名为 AV codec_register_all(),一会儿后,我固定链接问题,忘了...

When I transfered the source code from the example to the c++ application I made a stupid mistake when I got linker errors, that told me that av_register_all(); was unavailable... and I renamed it to avcodec_register_all(), a little while later I fixed the linker problem and forgot about it...

解决方案 AV codec_register_all()需要更改为 av_register_all()

这篇关于如何使用的Qt4 libav codeC?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆