将 DirectShow 库包含到 Qt 中以用于视频缩略图

发布于 2024-09-16 15:55:15 字数 1073 浏览 6 评论 0原文

我正在尝试实施 http:// msdn.microsoft.com/en-us/library/dd377634%28v=VS.85%29.aspx 在 Qt 上,为视频文件生成海报框架/缩略图。

我已经安装了 Windows Vista 和 Windows 7 SDK。我将:

#include "qedit.h"

在我的代码中(注意 C:\Qt\2010.04\mingw\include 中也有一个),我将: 添加

win32:INCLUDEPATH += $$quote(C:/WindowsSDK/v6.0/Include)

到我的 *.pro 文件中。我编译并得到“错误:sal.h:没有这样的文件或目录”。在 VC++ 中找到这个,我添加了

win32:INCLUDEPATH += $$quote(C:/Program Files/Microsoft Visual Studio 10.0/VC/include)

现在有 1400 个编译错误。因此,我放弃了这一点,只是将:

win32:LIBS += C:/WindowsSDK/v7.1/Lib/strmiids.lib

添加到我的 *.pro 文件中并尝试运行(不包含任何标头):

IMediaDet mediadet;

但随后我得到“错误:IMediaDet:没有这样的文件或目录”。

#include "qedit.h"

给了我同样的错误(看起来它指向 Qt 版本)并

#include "C:/WindowsSDK/v6.0/Include/qedit.h" 

返回生成 1000 个编译错误。

唉,10 行代码真是太麻烦了……

感谢您的评论和帮助

I'm trying to implement http://msdn.microsoft.com/en-us/library/dd377634%28v=VS.85%29.aspx on Qt, to generate a poster frame/thumbnail for video files.

I have installed both Windows Vista and Windows 7 SDK. I put:

#include "qedit.h"

in my code (noting there is also one in C:\Qt\2010.04\mingw\include), I add:

win32:INCLUDEPATH += $quote(C:/WindowsSDK/v6.0/Include)

to my *.pro file. I compile and get " error: sal.h: No such file or directory". Finding this in VC++ I add

win32:INCLUDEPATH += $quote(C:/Program Files/Microsoft Visual Studio 10.0/VC/include)

And now have 1400 compile errors. So, I abandon that and just add:

win32:LIBS += C:/WindowsSDK/v7.1/Lib/strmiids.lib

to my *.pro file and try to run (without including any headers):

IMediaDet mediadet;

But then I get "error: IMediaDet: No such file or directory".

#include "qedit.h"

gives me the same error (it looks like it's pointing to the Qt version) and

#include "C:/WindowsSDK/v6.0/Include/qedit.h" 

goes back to generating 1000's of compile errors.

Sigh, so much trouble for what should be 10 lines of code...

Thanks for your comments and help

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

财迷小姐 2024-09-23 15:55:15

既然你说你是“C++/Qt 新手”,那么我怀疑真正的问题可能是你试图自己加载库,而不是简单地将你的应用程序链接到它?

要使用 Qt 将外部库链接到您的应用程序,您所需要做的就是修改相应的 .pro 文件。例如,如果该库名为 libfoo.dll,您只需添加

LIBS += -L/path/to/lib -lfoo

您可以在 qmake 手册的相关部分。请注意,qmake 通常采用类似 Unix 的表示法,并且在 Windows 上透明地执行正确的操作。

完成此操作后,您可以包含库的标头并使用它提供的任何类和函数。请注意,您还可以修改项目文件以附加包含路径以帮助获取标头,例如。

INCLUDEPATH += /path/to/headers

同样,更多信息请参见qmake 手册的相关部分

请注意,这两个项目变量都使用相对路径,并且很乐意与 .. 一起使用,表示在所有平台上“转到目录”。

Since you say you are "a C++/Qt newbie" then I suspect that the real issue may be that you are attempting to load the library yourself rather than simply linking your application to it?

To link an external library into your application with Qt all you need to do is modify the appropriate .pro file. For example if the library is called libfoo.dll you just add

LIBS += -L/path/to/lib -lfoo

You can find more information about this in the relevant section of the qmake manual. Note that qmake commonly employs Unix-like notation and transparently does the right thing on Windows.

Having done this you can include the library's headers and use whatever classes and functions it provides. Note that you can also modify the project file to append an include path to help pick up the headers eg.

INCLUDEPATH += /path/to/headers

Again, more information in the relevant section of the qmake manual.

Note that both these project variables work with relative paths and will happily work with .. to mean "go up a directory" on all platforms.

心碎无痕… 2024-09-23 15:55:15

请注意,qedit.h 需要 dxtrans.h,它是 DirectX9 SDK 的一部分。

您可以在 DirectX SDK 中从 2006 年 8 月。请注意,dxtrans.h 已从较新的 DirectX SDK 中删除。

Note that qedit.h requires dxtrans.h, which is part of DirectX9 SDK.

You can find dxtrans.h in DirectX SDK from August 2006. Note that dxtrans.h is removed from newer DirectX SDKs.

柠栀 2024-09-23 15:55:15

您可以访问外部库的源吗?以下假设您这样做。

当我需要从仅解析函数的库中提取类时,我所做的就是使用库中的工厂函数。

// Library.h
class SomeClass {
public:
  SomeClass(std::string name);
  // ... class declaration goes here
};

在cpp文件中,当我的构造函数需要C++参数(例如std::string等类型)时,我在extern“C”之外使用代理函数,我将其作为指针传递以防止编译器弄乱C之间的签名和C++。如果构造函数不需要参数,则可以避免额外的步骤,并直接从导出函数调用 new SomeClass() 。

// Library.cpp
#include "Library.h"
SomeClass::SomeClass(std::string name)
{
// implementation details
}

// Proxy function to handle C++ types
SomeClass *ImplCreateClass(std::string* name) { return new SomeClass(*name); }

extern "C"
{
  // Notice the pass-by-pointer for C++ types
  SomeClass *CreateClass(std::string* name) { return ImplCreateClass(name); }
}

然后,在使用该库的应用程序中:

// Application.cpp
#include "Library.h"
typedef SomeClass* (*FactoryFunction)(std::string*);

// ...

QLibrary library(QString("MyLibrary"));
FactoryFunction factory = reinterpret_cast(library.resolve("CreateClass"));

std::string name("foobar");
SomeClass *myInstance = factory(&name);

您现在拥有库中声明的类的实例。

Do you have access to the source of the external library? The following assumes that you do.

What I do when I need to extract a class from a library with only functions resolved, is to use a factory function in the library.

// Library.h
class SomeClass {
public:
  SomeClass(std::string name);
  // ... class declaration goes here
};

In the cpp file, I use a proxy function outside the extern "C" when my constructor requires C++ parameters (e.g. types such as std::string), which I pass as a pointer to prevent the compiler from messing up the signature between C and C++. You can avoid the extra step if your constructor doesn't require parameters, and call new SomeClass() directly from the exported function.

// Library.cpp
#include "Library.h"
SomeClass::SomeClass(std::string name)
{
// implementation details
}

// Proxy function to handle C++ types
SomeClass *ImplCreateClass(std::string* name) { return new SomeClass(*name); }

extern "C"
{
  // Notice the pass-by-pointer for C++ types
  SomeClass *CreateClass(std::string* name) { return ImplCreateClass(name); }
}

Then, in the application that uses the library :

// Application.cpp
#include "Library.h"
typedef SomeClass* (*FactoryFunction)(std::string*);

// ...

QLibrary library(QString("MyLibrary"));
FactoryFunction factory = reinterpret_cast(library.resolve("CreateClass"));

std::string name("foobar");
SomeClass *myInstance = factory(&name);

You now hold an instance of the class declared in the library.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文