如何使用的Qt4 libav codeC?

编程入门 行业动态 更新时间:2024-10-22 20:41:52
本文介绍了如何使用的Qt4 libav codeC?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

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

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

验证该视频流可以通过libav $ C $立方厘米德$ C $光盘通过编译这个例子,我搬到源$ 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?

本文发布于:2023-10-09 18:28:02,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1476440.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   codeC   libav

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!