这是我关于堆栈溢出的第一个问题,所以请回答我。
我正在使用带有Qt 4.8.5,C++和Cmake 2.8的窗口7的libvlc库2.1.5win64来构建一个项目,以rtsp协议(protocol)从VLC服务器捕获流视频。我非常严重地面临两个问题。

遇到错误

[0000000001c96b20] main input error: open of 'rtsp"//192.168.1.101:8554/' failed

[0000000001bcce90] main input error: your input can't be opened
[0000000001bcce90] main input error: VLC is unable to open the MRL 'rtsp://192.168.1.101:8554/'. check the log for details.
请有人回答我的问题..............
我还为我的源代码提供了cmakelist .........
如果可能的话,请编辑我的代码,因为我是Qt,Cmake,LibVlc的新手
CmakeList.txt


cmake_minimum_required(VERSION 2.8)
PROJECT(VlcInterfaceWindow_FULL)
FIND_PACKAGE( Qt4 4.8.5 COMPONENTS QtMain QtCore QtGui REQUIRED )
#SET(VlcInterfaceWindow_SOURCES  main.cpp  vlc_on_qt.cpp)
SET(VlcInterfaceWindow_HEAERS vlc_on_qt.h)

INCLUDE(${QT_USE_FILE})
include_directories( "C:/vlc-2.1.5/sdk/include")
QT4_WRAP_CPP(VlcInterfaceWindow_HEAERS_MOC ${VlcInterfaceWindow_HEAERS})


add_library(lib_vlc STATIC IMPORTED)
set_property(TARGET lib_vlc PROPERTY IMPORTED_LOCATION_RELEASE C:/vlc-2.1.5/sdk/lib/libvlc.lib)
set_property(TARGET lib_vlc PROPERTY IMPORTED_LOCATION_DEBUG C:/vlc-2.1.5/sdk/lib/libvlc.lib)

add_library(lib_vlc_core STATIC IMPORTED)
set_property(TARGET lib_vlc_core PROPERTY IMPORTED_LOCATION_RELEASE C:/vlc-
2.1.5/sdk/lib/libvlccore.lib)
set_property(TARGET lib_vlc_core PROPERTY IMPORTED_DEBUG C:/vlc-2.1.5/sdk/lib/libvlccore.lib)
set(VlcTest_SRCS  main.cpp vlc_on_qt.cpp )

ADD_EXECUTABLE(VlcInterfaceWindow_FULL ${VlcTest_SRCS} ${VlcInterfaceWindow_HEAERS_MOC})
TARGET_LINK_LIBRARIES(VlcInterfaceWindow_FULL ${QT_LIBRARIES} lib_vlc lib_vlc_core)



main.cpp

#include "vlc_on_qt.h"
#include <QtGui/QApplication>

int main(int argc, char *argv[])
{
QApplication a(argc, argv);
Player p;
p.resize(640,480);
//p.playFile("rtsp://38.117.88.90/TenTV/video");
p.playFile("rtsp://192.168.1.101:8554/");
p.show();
return a.exec();
}





vlc_on_qt.h

#ifndef VLC_ON_QT_H
#define VLC_ON_QT_H

#include <vlc/vlc.h>
#include <vlc/libvlc.h>
#include <QWidget>

class
QVBoxLayout;
class
QTimer;
class
QFrame;
class
QSlider;

#define POSITION_RESOLUTION 10000

class Player : public QWidget
{
Q_OBJECT

QSlider *_positionSlider;

QFrame *_videoWidget;
QTimer *poller;
bool _isPlaying;
libvlc_instance_t *_vlcinstance;
libvlc_media_player_t *_mp;
libvlc_media_t *_m;

public:
Player();
〜Player();
public slots:
void playFile(QString file);
void updateInterface();
void changePosition(int newPosition);
};
#endif



vlc_on_qt.cpp

#include "vlc_on_qt.h"
#include <QVBoxLayout>
#include <QPushButton>
#include <QSlider>
#include <QTimer>
#include <QFrame>
#include <iostream>

using namespace std;

Player::Player()
: QWidget()
{

 _videoWidget=new QFrame(this);

_positionSlider=new QSlider(Qt::Horizontal,this);
_positionSlider->setMaximum(POSITION_RESOLUTION);

QVBoxLayout *layout = new QVBoxLayout;
layout->addWidget(_videoWidget);
layout->addWidget(_positionSlider);
setLayout(layout);

_isPlaying=false;
poller=new QTimer(this);

connect(poller, SIGNAL(timeout()),this, SLOT(updateInterface()));
connect(_positionSlider, SIGNAL(sliderMoved(int)), this, SLOT(changePosition(int)));

poller->start(100);
}

Player::~Player()
{
libvlc_media_player_stop (_mp);

libvlc_media_player_release (_mp);

libvlc_release (_vlcinstance);

}

void Player::playFile(QString file)
{
 _vlcinstance=libvlc_new(0, NULL);

 //Create a new LibVLC media descriptor
_m = libvlc_media_new_location(_vlcinstance, file.toAscii());

_mp=libvlc_media_player_new_from_media (_m);


// Get our media instance to use our window
 libvlc_media_player_set_hwnd(_mp, _videoWidget->winId());

// Play
libvlc_media_player_play (_mp);

_isPlaying=true;

}


void Player::changePosition(int newPosition)
{
libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp);
if (curMedia == NULL)
    return;

float pos=(float)(newPosition)/(float)POSITION_RESOLUTION;
libvlc_media_player_set_position (_mp, pos);

}

void Player::updateInterface()
{
if(!_isPlaying)
    return;

libvlc_media_t *curMedia = libvlc_media_player_get_media (_mp);
if (curMedia == NULL)
    return;

float pos=libvlc_media_player_get_position (_mp);
int siderPos=(int)(pos*(float)(POSITION_RESOLUTION));
_positionSlider->setValue(siderPos);

}

最佳答案

vlc发行版中的libvlc.lib始终被破坏,无法与Visual Studio版本一起使用。要解决此问题,您有3种选择:

  • 使用/ OPT:NOREF链接器选项进行发行版本;
  • 使用Visual Studio的命令行工具(借助于Videolan Wiki)从libvlc.dll生成libvlc.lib;
  • 使用prebuild libvlc.lib from my libvlc.lib generation project on Google Codefrom my libvlc sdk on GitHub;

  • 并找出视频解码出了什么问题,可以将“-vvv”(激活完整调试日志的选项)传递给libvlc_new

    关于c++ - 在 Release模式下崩溃并在 Debug模式下遇到错误,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/27958455/

    10-11 18:56