How can i get an streaming video from an IP Camera or DVR ?



  • Hi every body,

    How can I get an streaming video from an IP camera or DVR in QT? I use widgets, QT 5.3.2 .
    I have vivotek Camera model IP7130 but I want my app to be compatible with most of Cameras! I found somethings about RTSP Protocol or Camera SDK but I didn't understand how to use them. Please help me.

    Thanks.



  • Qt don't have support for RTSP, it do have multimedia module but this still won't help to achieve that.
    To connect and receive frames from camera's third party libraries like libVlc or FFmpeg could be used.
    libVlc is simple enough - You even can test this library to see if it will work with Your camera by using VLCPlayer, just connect to camera and see if this do work. If it does, then just use it with Qt. Qt will be Ui library allowing You to display received video frames (and / or sound) and libVlc to acquire data from web cam. Same for FFmpeg.



  • @LuGRU
    Thank you for answering.
    I checked libVLC ! I installed it and compiled simple player of github. But at running the app crashed. I don't know why! I use windows 7 32 bit and qt 5.3.2. I used libVLC of github!

    I searched a lot for the problem but most of them were for linux and a few for windows which didn't have a good solution.

    Do you have any idea?



  • If application crash on start then You probably forgot to place either libvlc dll's into application directory or plugin directory.
    Download fastest solution, download VLCPlayer and copy "plugins" directory and libvlc.dll + libvlccore.dll into app directory.

    BTW. google around and You will find Qt wrapper for libvlc, and second more mature project with all widget and simple API (this one uses FFmpeg), sorry forgot names of those projects.



  • @LuGRU
    I downloaded vlcplayer last version and installed it, then copied plugins folder + libvlc.DLL + libvlccore.DLL from installation folder in Program Files dir , and pasted in my app directory next to .pro file of my qt projet. Again app crashed just after building!
    Qt says :
    the program has unexpectedly finished.
    E:\.........\myprog.exe crashed

    I checked debug mode to find the line which has problem but debug is finished just after starting and says the error:
    During startup program exited with code 0xc0000135

    I checked plugins Dir of my libVLC but it didn't work too.

    Please help me if I forgot sth.



  • Here is my simple Code:

    vlcplayer.pro :

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    TARGET = vlcplayer
    TEMPLATE = app
    
    
    SOURCES += main.cpp\
            mainwindow.cpp
    
    HEADERS  += mainwindow.h
    
    FORMS    += mainwindow.ui
    
    LIBS       += -lvlc-qt -lvlc-qt-widgets
    
    LIBS += -LE:\Qt\libvlc\lib
    INCLUDEPATH += E:\Qt\libvlc\include\
    

    main.cpp :

    #include "mainwindow.h"
    #include <QApplication>
    #include <vlc-qt/Common.h>
    #include <QDebug>
    
    int main(int argc, char *argv[])
    {
        QApplication app(argc, argv);    
    
        VlcCommon::setPluginPath(app.applicationDirPath() + "/plugins");     //if I comment this line app will start correctly.
    
        MainWindow w;
        w.show();
    
        return app.exec();
    }
    

    mainwindow.h :

    #include <QMainWindow>
    
    namespace Ui {
    class MainWindow;
    }
    
    
    class MainWindow : public QMainWindow
    {
        Q_OBJECT
    
    public:
        explicit MainWindow(QWidget *parent = 0);
        ~MainWindow();
    
    private:
        Ui::MainWindow *ui;
    };
    

    mainwindow.cpp :

    #include "mainwindow.h"
    #include "ui_mainwindow.h"
    
    MainWindow::MainWindow(QWidget *parent) :
        QMainWindow(parent),
        ui(new Ui::MainWindow)
    {
        ui->setupUi(this);
    }
    
    MainWindow::~MainWindow()
    {
        delete ui;
    }
    

    mainwindow.ui :

    <?xml version="1.0" encoding="UTF-8"?>
    <ui version="4.0">
     <class>MainWindow</class>
     <widget class="QMainWindow" name="MainWindow">
      <property name="geometry">
       <rect>
        <x>0</x>
        <y>0</y>
        <width>400</width>
        <height>300</height>
       </rect>
      </property>
      <property name="windowTitle">
       <string>MainWindow</string>
      </property>
      <widget class="QWidget" name="centralWidget"/>
      <widget class="QMenuBar" name="menuBar">
       <property name="geometry">
        <rect>
         <x>0</x>
         <y>0</y>
         <width>400</width>
         <height>21</height>
        </rect>
       </property>
      </widget>
      <widget class="QToolBar" name="mainToolBar">
       <attribute name="toolBarArea">
        <enum>TopToolBarArea</enum>
       </attribute>
       <attribute name="toolBarBreak">
        <bool>false</bool>
       </attribute>
      </widget>
      <widget class="QStatusBar" name="statusBar"/>
     </widget>
     <layoutdefault spacing="6" margin="11"/>
     <resources/>
     <connections/>
    </ui>
    

    Is there any thing wrong in my code?
    please help?



  • I downloaded vlcplayer last version and installed it, then copied plugins folder + libvlc.DLL + libvlccore.DLL from installation folder in Program Files dir , and pasted in my app directory next to .pro file of my qt projet.

    You need to paste those files to directory where binary is (.exe).



  • @LuGRU
    I copied them where .exe is, but again it didn't work. it just same as before!
    Maybe I should do sth in libVLC like build or update or cache! is it right?
    perhaps I'm using wrong lib! could you give me a right URL for libVLC for Win7 32bit? I will check it.
    Maybe the problem is related to cmake or qmake! I think qt use qmake as default and I don't know how to enable cmake? even I dont know what are these....
    its hopeless that i couldn't run a simple app!



  • the app started, I must have copied libvlc-qt.dll + libvlc-qt-widgets.dll too, where .exe is.

    but another problem comes. when I promote a widget to VlcVideoWidget Class just before starting Microsoft Visual C++ Runtime Library comes up with a error that says: "This application has requested the Runtime to terminate it in an unusual way".

    after pressing "OK" in error window, windows says: "myapp.exe has stpped working".

    and qt says:
    QWidget: Must contrust a QApplication before a QWidget
    Invalid parameter passed to C runtime function.
    Invalid parameter passed to C runtime function.

    I got angry. problem after problem..... any idea?



  • Is anybody here who have worked with libVLC without any problem?

    is it a convenience library or a lib with a lot of problem?

    please help me?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.