简体   繁体   中英

Crashing in Release Mode and error encounter in Debug Mode

Its my first question on stack overflow, so please answer me.

I am using libvlc library 2.1.5win64 for window 7 with Qt 4.8.5, C++ and Cmake 2.8 to build a project that capture a streaming video from VLC server in rtsp protocol. I am facing two problems very badly.

1: My program is bulding .exe file in Release mode but it crash when we open(double click) this .exe file, while it is working correctly in debug mode.

2: My program is not working in debug mode also, when I open .exe file it shown a widget but video is not streaming

it encounters a error

[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.

Please somebody anserw my question..............

I am also providing my source code with cmakelist............

If possible please edit my code because i am new on 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);

}

libvlc.lib from vlc distribution was always broken for use with release Visual Studio builds. To solve this issue you have 3 options:

And to find out what is wrong with video deconding, you could pass "-vvv" (option to activate full debug log) to libvlc_new

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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