我正在使用libvlc库2.1.5win64 for Windows 7,使用Qt 4.8.5,C ++,Cmake 2.8和Visual Studio 2010构建一个捕获rtsp流视频的项目。我面临的问题非常严重。
HTTP流媒体链接正常工作,但RTSP流媒体链接无法正常工作。它给出了一个错误:
[00000000003b7b80] access_realrtsp访问警告:目前仅支持real / helix rtsp服务器
[00000000003b7b80]主要访问调试:没有匹配的访问模块
[00000000003a3c60]主要输入错误:打开 'rtsp://quicktime.uvm.edu:1554 / waw / wdi05hs2b.mov'失败了 [00000000003a3c60]主要输入错误:您的输入无法打开
[00000000003a3c60]主要输入错误:VLC无法打开MRL 'RTSP://quicktime.uvm.edu:1554 / WAW / wdi05hs2b.mov'。检查日志 的信息。
的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);
/*This link is working properly*/
//p.playFile("http://qn.vc/files/data/3278/Dost%20-%20Abida%20Parveen%20-%20Coke%20Studio%20Pakistan,%20Season%207,%20Episode%203[mobmp4.com].mp4");
/*This link is not working and encounter an error*/
p.playFile("rtsp://quicktime.uvm.edu:1554/waw/wdi05hs2b.mov");
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)
{
const char * const vlc_args[] = { "--verbose=4" };
_vlcinstance=libvlc_new(sizeof(vlc_args)/sizeof(vlc_args[0]), vlc_args);
//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);
}