Qt 5 和 LibVLC [英] Qt 5 and LibVLC

查看:52
本文介绍了Qt 5 和 LibVLC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从事一个项目,该项目涉及接收、显示和转播多个本地网络视频流.LibVLC 似乎是要走的路,我想在 Qt Creator/C++/OSX 10.12.1 中使用它,并且我还需要在安装了 Qt 的某些 Windows 10 机器上编译该项目.

通过从 projects.tano.si/vlc-qt 安装官方 QT-LibVLC 包装器,我成功地测试了一些功能.不幸的是,包装器缺少许多对我的项目必不可少的 LibVLC 方法,因此我决定安装完整的 LibVLC.

现在我被困在如何使 LibVLC 工作上.我遵循了

然后选择添加库选项.

然后助手打开:

并选择导入类型,在您的情况下,建议使用External Library.

然后您查找项目的位置并接受.

注意:在Linux中,这个工具可以用快捷键Ctrl + E

打开

I'm working on a project which involves receive, display and rebroadcast several local network video streams. LibVLC seems to be the way to go, I'd like to use it within Qt Creator/C++/OSX 10.12.1 and I also need the project to be compilable on some Windows 10 machines where I have Qt installed.

I successfully tested some functionalities by installing the offical QT-LibVLC wrapper from projects.tano.si/vlc-qt. Unfortunately the wrapper lacks many LibVLC methods which are essential to my project, so I decided to install full LibVLC.

For now I'm stuck on how to make LibVLC work. I followed all directions at https://wiki.videolan.org/OSXCompile/#Apple_Software for installation and libraries building, and everything went fine.

Then I started a new project in QT, tried adding INCLUDEPATH += . vlc and LIBS +=-lvlc paths to the .pro file in Qt, but it does not work. Also adding paths to the "Framework" folder of the VLC build folder doesn't work.

Anyone knows how the magic trick? Sorry, I know I'm a bit naive, but that's it... Thank you in advance for any answer!

UPDATE:

thanks to eyllanesc suggestion this structure now works for the compiler:

QT       += core gui

greaterThan(QT_MAJOR_VERSION, 4): QT += widgets

TARGET = testVLC
TEMPLATE = app

DEFINES += QT_DEPRECATED_WARNINGS

SOURCES += \
player.cpp \
main.cpp

HEADERS += \
player.h


macx: LIBS += -L$$PWD/../../../../Users/macbookpro15retina/Documents/vlc/build/vlc_install_dir/lib/ -lvlc.5

INCLUDEPATH += $$PWD/../../../../Users/macbookpro15retina/Documents/vlc/build/vlc_install_dir/include
DEPENDPATH += $$PWD/../../../../Users/macbookpro15retina/Documents/vlc/build/vlc_install_dir/include

Unfortunately the application is launched but VLC instance is not initialized. Seems that my VLC installation has something wrong.

SOLVED:

After some tweaking the project compiles and starts correctly. I don't understand why, but the environment variable VLC_PLUGIN_PATH has to be set just before instantiating VLC, otherwise VLC refuses to initialize:

//set environment variable VLC_PLUGIN_PATH
int s = setenv ("VLC_PLUGIN_PATH",  "/Users/macbookpro15retina/Documents/vlc/build/vlc_install_dir/lib/vlc/plugins", 1);

// Initialize libVLC 
vlcInstance = libvlc_new(0, NULL);

Actually it doesn't work at all if you set it in the Build Environment of QtCreator.

解决方案

A simple way to include libraries for our application is with the help of Qt Creator, this one has an assistant, to be able to use it just right click on the name of your project:

Then select the Add Library option.

Then the assistant opened:

And select the type of import, in your case it is advisable to use External Library.

Then you look for the location of your project and you accept.

Note: In Linux this tool can be opened with the shortcut Ctrl + E

这篇关于Qt 5 和 LibVLC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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