Axis camera RTSP with QMediaPlayer issue
-
Hi!
I am new to Qt and would like to ask advice. I want to stream the video from an Axis A8105-E IP camera. The same RTSP stream URL works in VLC and with OpenCV. However, using the QMediaPlayer only a few frames of the video displays and then the video freezes, but audio is still coming through. An exception is thrown when debugging (in EVR!MFCreateVideoSampleAllocator). So I can access the camera, but I think there are some incompatible settings between the camera and codec used, causing the video to fail?Details:
Windows 10 64-bit application
Qt 5.13.0 using Kit Desktop MSVC2017 64 bit
Codecs installed at the moment: K-lite codec pack Full (recommended installation)My mainwindow.cpp
#include "mainwindow.h" #include "ui_mainwindow.h" #include <QDebug> #include <QGridLayout> #include <QMediaPlayer> #include <QVideoWidget> MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); setWindowTitle("RTSP test Axis camera"); QVideoWidget *_vw1 = new QVideoWidget; QMediaPlayer *_player1 = new QMediaPlayer; QGridLayout *layout = new QGridLayout; layout->addWidget(_vw1); QWidget *win = new QWidget(); win->setLayout(layout); setCentralWidget(win); _player1->setVideoOutput(_vw1); _player1->setMedia(QUrl("rtsp://username:password@XXX.XXX.XXX.XXX/axis-media/media.amp?videocodec=h264&resolution=640x480")); //XXX = ip address _vw1->setGeometry(100,100,640,480); _vw1->show(); _player1->play(); } MainWindow::~MainWindow() { delete ui; }
Can you please provide any guidance/recommendations based on experience where Axis cameras have been integrated with Qt on Windows? I am happy to try a different codec if you can recommend any known to work.
Thank you for your help!
-
Hi and welcome to devnet,
Since you have it already running with VLC, you might want to consider using the VLC-Qt project that integrates both together.
-
@sgaist said in Axis camera RTSP with QMediaPlayer issue:
welcome to devnet,
Since you have it already running with VLC, you might want to consider using the VLC-Qt project that integrates both togetheHi, thanks for your response. I did try that, I started to follow these instructions http://derekmolloy.ie/custom-video-streaming-player-using-libvlc-and-qt/ but soon got derailed. I downloaded the latest version from https://github.com/vlc-qt/vlc-qt/releases and tried to follow these steps to build with MSVC2017 https://github.com/vlc-qt/vlc-qt/issues/239 (as it is one of my requirements to use 64-bit MSVC 2017), but at the nmake step I got fatal errors and did not know how to continue.
I also wanted to try this https://download.videolan.org/pub/videolan/x264/binaries/win64/ as I think it is the codec used by VLC for my purposes, but I don't know how to install it, nothing happens when I click on the .exe file.
I will greatly appreciate any further guidance.
-
What exact error did you get ?
-
@sgaist said in Axis camera RTSP with QMediaPlayer issue:
ou might want to consider using the VLC-Qt project that integrates both together.
Hi, thank you for your response. The inital errors I got when posting the previous message has been resolved - the header files weren't present in the vlc download. But now I have different errors.
When using nmake I got this error: module machine type x64 conflicts with target machine type x86. So I know the problem is that mismatch, but I haven't been able to solve it.
Then I also tried to use ninja but got this error: FindDirstFileExA(C:/qt/vlc-3.0.8-win64/vlc-3.0.8): The filename, directory name, or volume label syntax is incorrect. I also haven't been able to solve that yet.
Thanks!
-
Looks like you are trying to link against something built for 64 bit while building your application is built in 32bits.
-
Thought I would come update this in case it might help someone in future.
I moved to a QML application. There I use the "Video" QML Type, with source set to the stream url. The correct Axis codecs are required (which you can get when installing AXIS Media Control SDK) and the url structure to use is: axrtsphttp://username:password@IPaddress/axis-media/media.amp?videocodec=h264&camera=3&date=1&clock=1&text=1&resolution=1600x1200 specifying your specifics.
Happy coding!