繁体   English   中英

在发布模式下崩溃,在调试模式下遇到错误

[英]Crashing in Release Mode and error encounter in Debug Mode

这是我关于堆栈溢出的第一个问题,所以请回答我。

我正在使用带有Qt 4.8.5,C ++和Cmake 2.8的窗口7的libvlc库2.1.5win64来构建一个项目,以rtsp协议从VLC服务器捕获流视频。 我非常严重地面临两个问题。

1:我的程序在发布模式下正在扩展.exe文件,但当它在调试模式下正常运行时,当我们打开(双击)此.exe文件时,它崩溃。

2:我的程序也无法在调试模式下工作,当我打开.exe文件时,它显示了一个小部件,但视频没有流

遇到错误

[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();

〜播放器();

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种选择:

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

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM