我尝试使用libvlc来播放RTSP流。这是我的代码:
MainWindow::MainWindow(QWidget *parent) :
QMainWindow(parent),
ui(new Ui::MainWindow)
{
ui->setupUi(this);
const char* fileName = "rtsp://184.72.239.149/vod/mp4://BigBuckBunny_175k.mov";
int windId = this->winId();
libvlc_instance_t *instance = libvlc_new(0, NULL);
libvlc_media_t *vlcMedia = libvlc_media_new_location(instance, fileName);
libvlc_media_player_t* player = libvlc_media_player_new_from_media(vlcMedia);
libvlc_media_player_set_xwindow(player, windId);
libvlc_media_player_play(player);
}
问题是libvlc会向服务器发送一个SETUP命令,如下所示:
SETUP rtsp://184.72.239.149:554/vod/mp4://bigbuckbunny_175k.mov RTSP/1.0
它与vlc播放器完全不同。 vlc播放器发送的是:
SETUP rtsp://184.72.239.149:554/vod/mp4://bigbuckbunny_175k.mov/trackID=0
SETUP rtsp://184.72.239.149:554/vod/mp4://bigbuckbunny_175k.mov/trackID=1
答案 0 :(得分:0)
libvlc中有多个RTSP访问插件。 确保您使用的是live555而不是realrtsp。