Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. OUT OF 2, ONE OF THE CAMERA STREAMING FREEZES SOMETIMES

OUT OF 2, ONE OF THE CAMERA STREAMING FREEZES SOMETIMES

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
3 Posts 2 Posters 449 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bharat7491
    wrote on last edited by aha_1980
    #1

    I am using crosscontrol V1200 display , in which I use Qt5 to develop my app . one of it's screens stream the 2 ip cameras but sometimes , one of the cameras is getting slow. How to avoid it.here is the code:

    #include "video1.h"
    #include "ui_video1.h"
    #include <QProcess>
    #include <qquickview.h>
    #include <QQmlContext>
    #include <QQuickItem>
    #include <QQuickWindow>
    #include <QQmlEngine>
    #include <QQmlComponent>
    #include <QQmlProperty>
    #include <QImage>
    #include <QQuickItem>
    #include <QQuickWindow>
    #include "gst_pipeline.h"
    #include "gstplayerjob.h"
    #include "gst_pipeline2.h"
    #include "gstplayerjob2.h"
    #include <gst/gst.h>
    #include <QFileInfo>
    #include <glib.h>
    
    #define STREAMING_PORT 50004
    
    const QString URL = "rtsp://192.168.0.50:554/mainstream";
    const QString URL2 = "rtsp://192.168.0.60:554/mainstream";
    
    video1 * video1 :: video_instance = 0;
    video1  *  video1:: video_current_instance()
    {
        if (!video1::video_instance){
    
            if (!video1::video_instance){
    
                video1::video_instance = new video1;
            }return video1::video_instance;
        }
    
        return video1::video_instance;
    }
    
    video1::video1(QWidget *parent) :
        QWidget(parent),
        ui(new Ui::video1)
    {
        ui->setupUi(this);
        ui->stackedWidget->setCurrentIndex(0);
    
        ui->pushButton_cam1_2->hide();
    
        iTime_v = 0;
    
        video_timer=new QTimer();
        connect(video_timer,SIGNAL(timeout()),this,SLOT(video_run_timer_slot()));
        video_timer->start(1000);
    }
    
    video1::~video1()
    {
        cleanupCameras();
        delete ui;
    }
    
    void video1::video_run_timer_slot()
    {
      iTime_v = iTime_v + 1;
    
      if(iTime_v == 5)
      {
         setupCamera(URL, ui->quickWidget);
      }
    
      if(iTime_v == 10)
      {
         setupCamera(URL2, ui->quickWidget_2);
         video_timer->stop();
      }
    }
    
    void video1::setupCamera(const QString &cameraUrl, QQuickWidget *quickWidget)
    {
        qDebug()<<"setting up camera with URL"<<cameraUrl;
        GstElement *pipeline = gst_pipeline_new("my-pipeline");
        GstElement *sink = configureH264RtspVideoStreamPipeline(pipeline, cameraUrl);
    
        quickWidget->setSource(QUrl::fromLocalFile(":/camera.qml"));
    
    
        QQuickItem *rootObject = quickWidget->rootObject();
        QQuickItem *videoItem = rootObject->findChild<QQuickItem *>("videoItem");
        Q_ASSERT(videoItem);
    
        g_object_set(sink, "widget", videoItem, NULL);
    
        rootObject->window()->scheduleRenderJob(new GstPlayerJob(pipeline), QQuickWindow::BeforeSynchronizingStage);
    
        GstPlayerInfo playerInfo;
        playerInfo.pipeline = pipeline;
        playerInfo.sink = sink;
        playerInfo.quickWidget = quickWidget;
    
        cameraInfoList.append(playerInfo);
    
        gst_element_set_state(pipeline, GST_STATE_PLAYING);
    
        qDebug()<<"camera set up completed";
    }
    
    void video1::cleanupCameras()
    {
        qDebug()<<"Cleaning up cameras.";
        for (const auto &cameraInfo : cameraInfoList) {
            gst_element_set_state(cameraInfo.pipeline, GST_STATE_NULL);
            gst_object_unref(cameraInfo.pipeline);
            gst_object_unref(cameraInfo.sink);
        }
        cameraInfoList.clear();
        qDebug()<<"camera clean up completed";
    }
    
    void video1::on_pushButton_cam1_released()
    {
        ui->quickWidget->setGeometry(60,90,1161,641);
        ui->quickWidget_2->hide();
    
        ui->pushButton_cam1_2->show();
        ui->pushButton_cam1->hide();
        ui->pushButton_cam2->hide();
    }
    
    void video1::on_pushButton_cam1_2_released()
    {
        ui->quickWidget->setGeometry(50,200,571,351);
        ui->quickWidget_2->setGeometry(661,200,571,351);
        ui->pushButton_cam1_2->hide();
        ui->quickWidget_2->show();
        ui->quickWidget->show();
    
        ui->pushButton_cam1->show();
        ui->pushButton_cam2->show();
    }
    
    void video1::on_pushButton_cam2_released()
    {
        ui->quickWidget_2->setGeometry(60,90,1161,641);
        ui->quickWidget->hide();
    
        ui->pushButton_cam1_2->show();
        ui->pushButton_cam1->hide();
        ui->pushButton_cam2->hide();
    }
    
    void video1::startStreaming()
    {
        ui->quickWidget->setGeometry(50,200,571,351);
        ui->quickWidget_2->setGeometry(661,200,571,351);
        ui->pushButton_cam1_2->hide();
        ui->quickWidget_2->show();
        ui->quickWidget->show();
        ui->pushButton_cam1->show();
        ui->pushButton_cam2->show();
    }
    
    void video1::stopStreaming()
    {
    }
    

    [Edit aha_1980: Added code tags]

    B 1 Reply Last reply
    0
    • B bharat7491

      I am using crosscontrol V1200 display , in which I use Qt5 to develop my app . one of it's screens stream the 2 ip cameras but sometimes , one of the cameras is getting slow. How to avoid it.here is the code:

      #include "video1.h"
      #include "ui_video1.h"
      #include <QProcess>
      #include <qquickview.h>
      #include <QQmlContext>
      #include <QQuickItem>
      #include <QQuickWindow>
      #include <QQmlEngine>
      #include <QQmlComponent>
      #include <QQmlProperty>
      #include <QImage>
      #include <QQuickItem>
      #include <QQuickWindow>
      #include "gst_pipeline.h"
      #include "gstplayerjob.h"
      #include "gst_pipeline2.h"
      #include "gstplayerjob2.h"
      #include <gst/gst.h>
      #include <QFileInfo>
      #include <glib.h>
      
      #define STREAMING_PORT 50004
      
      const QString URL = "rtsp://192.168.0.50:554/mainstream";
      const QString URL2 = "rtsp://192.168.0.60:554/mainstream";
      
      video1 * video1 :: video_instance = 0;
      video1  *  video1:: video_current_instance()
      {
          if (!video1::video_instance){
      
              if (!video1::video_instance){
      
                  video1::video_instance = new video1;
              }return video1::video_instance;
          }
      
          return video1::video_instance;
      }
      
      video1::video1(QWidget *parent) :
          QWidget(parent),
          ui(new Ui::video1)
      {
          ui->setupUi(this);
          ui->stackedWidget->setCurrentIndex(0);
      
          ui->pushButton_cam1_2->hide();
      
          iTime_v = 0;
      
          video_timer=new QTimer();
          connect(video_timer,SIGNAL(timeout()),this,SLOT(video_run_timer_slot()));
          video_timer->start(1000);
      }
      
      video1::~video1()
      {
          cleanupCameras();
          delete ui;
      }
      
      void video1::video_run_timer_slot()
      {
        iTime_v = iTime_v + 1;
      
        if(iTime_v == 5)
        {
           setupCamera(URL, ui->quickWidget);
        }
      
        if(iTime_v == 10)
        {
           setupCamera(URL2, ui->quickWidget_2);
           video_timer->stop();
        }
      }
      
      void video1::setupCamera(const QString &cameraUrl, QQuickWidget *quickWidget)
      {
          qDebug()<<"setting up camera with URL"<<cameraUrl;
          GstElement *pipeline = gst_pipeline_new("my-pipeline");
          GstElement *sink = configureH264RtspVideoStreamPipeline(pipeline, cameraUrl);
      
          quickWidget->setSource(QUrl::fromLocalFile(":/camera.qml"));
      
      
          QQuickItem *rootObject = quickWidget->rootObject();
          QQuickItem *videoItem = rootObject->findChild<QQuickItem *>("videoItem");
          Q_ASSERT(videoItem);
      
          g_object_set(sink, "widget", videoItem, NULL);
      
          rootObject->window()->scheduleRenderJob(new GstPlayerJob(pipeline), QQuickWindow::BeforeSynchronizingStage);
      
          GstPlayerInfo playerInfo;
          playerInfo.pipeline = pipeline;
          playerInfo.sink = sink;
          playerInfo.quickWidget = quickWidget;
      
          cameraInfoList.append(playerInfo);
      
          gst_element_set_state(pipeline, GST_STATE_PLAYING);
      
          qDebug()<<"camera set up completed";
      }
      
      void video1::cleanupCameras()
      {
          qDebug()<<"Cleaning up cameras.";
          for (const auto &cameraInfo : cameraInfoList) {
              gst_element_set_state(cameraInfo.pipeline, GST_STATE_NULL);
              gst_object_unref(cameraInfo.pipeline);
              gst_object_unref(cameraInfo.sink);
          }
          cameraInfoList.clear();
          qDebug()<<"camera clean up completed";
      }
      
      void video1::on_pushButton_cam1_released()
      {
          ui->quickWidget->setGeometry(60,90,1161,641);
          ui->quickWidget_2->hide();
      
          ui->pushButton_cam1_2->show();
          ui->pushButton_cam1->hide();
          ui->pushButton_cam2->hide();
      }
      
      void video1::on_pushButton_cam1_2_released()
      {
          ui->quickWidget->setGeometry(50,200,571,351);
          ui->quickWidget_2->setGeometry(661,200,571,351);
          ui->pushButton_cam1_2->hide();
          ui->quickWidget_2->show();
          ui->quickWidget->show();
      
          ui->pushButton_cam1->show();
          ui->pushButton_cam2->show();
      }
      
      void video1::on_pushButton_cam2_released()
      {
          ui->quickWidget_2->setGeometry(60,90,1161,641);
          ui->quickWidget->hide();
      
          ui->pushButton_cam1_2->show();
          ui->pushButton_cam1->hide();
          ui->pushButton_cam2->hide();
      }
      
      void video1::startStreaming()
      {
          ui->quickWidget->setGeometry(50,200,571,351);
          ui->quickWidget_2->setGeometry(661,200,571,351);
          ui->pushButton_cam1_2->hide();
          ui->quickWidget_2->show();
          ui->quickWidget->show();
          ui->pushButton_cam1->show();
          ui->pushButton_cam2->show();
      }
      
      void video1::stopStreaming()
      {
      }
      

      [Edit aha_1980: Added code tags]

      B Offline
      B Offline
      bharat7491
      wrote on last edited by
      #2

      @bharat7491

      here is the debug file :

      0:01:34.619762250  481 0xaaab02bde400 WARN   glwindow gstglwindow.c:340:gst_gl_window_new: Could not create window. user specified (null), creating dummy window
      0:01:34.633832000  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:2128:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

      0:01:34.634005375  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3165:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unsupported field type for H264@1x1: 0
      0:01:34.634110500  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3175:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unable to try format: Inappropriate ioctl for device
      0:01:34.634165375  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3047:gst_v4l2_object_probe_caps_for_format:v4l2h264dec:sink Could not probe minimum capture size for pixelformat H264
      0:01:34.634214500  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:2128:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

      0:01:34.634272250  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3165:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unsupported field type for H264@32768x32768: 0
      0:01:34.634320375  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3175:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unable to try format: Inappropriate ioctl for device
      0:01:34.634371125  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3053:gst_v4l2_object_probe_caps_for_format:v4l2h264dec:sink Could not probe maximum capture size for pixelformat H264
      0:01:34.654586500  481 0xaaab02bde400 WARN   glwindow gstglwindow.c:340:gst_gl_window_new: Could not create window. user specified (null), creating dummy window
      0:01:34.665603500  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:2128:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

      0:01:34.665797250  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3165:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unsupported field type for H264@1x1: 0
      0:01:34.665912750  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3175:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unable to try format: Inappropriate ioctl for device
      0:01:34.665967750  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3047:gst_v4l2_object_probe_caps_for_format:v4l2h264dec:sink Could not probe minimum capture size for pixelformat H264
      0:01:34.666014125  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:2128:gst_v4l2_object_get_interlace_mode: Driver bug detected - check driver with v4l2-compliance from http://git.linuxtv.org/v4l-utils.git

      0:01:34.666071750  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3165:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unsupported field type for H264@32768x32768: 0
      0:01:34.666123875  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3175:gst_v4l2_object_get_nearest_size:v4l2h264dec:sink Unable to try format: Inappropriate ioctl for device
      0:01:34.666177125  481 0xaaab02bde400 WARN   v4l2 gstv4l2object.c:3053:gst_v4l2_object_probe_caps_for_format:v4l2h264dec:sink Could not probe maximum capture size for pixelformat H264
      0:01:34.737486625  481 0xffff2c003360 FIXME   default gstutils.c:4025:gst_pad_create_stream_id_internal:fakesrc1:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
      0:01:34.738597750  481 0xffff2c003800 FIXME   default gstutils.c:4025:gst_pad_create_stream_id_internal:fakesrc2:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
      0:01:34.742942000  481 0xffff2c003860 FIXME   default gstutils.c:4025:gst_pad_create_stream_id_internal:fakesrc0:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
      0:01:34.742941875  481 0xffff2c0038c0 FIXME   default gstutils.c:4025:gst_pad_create_stream_id_internal:fakesrc3:src Creating random stream-id, consider implementing a deterministic way of creating a stream-id
      Failed to link source pad to depayloader pad.
      0:01:34.806878500  481 0xffff3405ef00 WARN   rtpjitterbuffer rtpjitterbuffer.c:575:calculate_skew: delta - skew: 0:00:01.150625611 too big, reset skew

      1 Reply Last reply
      0
      • SGaistS Offline
        SGaistS Offline
        SGaist
        Lifetime Qt Champion
        wrote on last edited by
        #3

        Hi and welcome to devnet,

        I am no GStreamer expert but here you are creating twice the same pipeline with the same name. Does it have an influence ?
        Then you are connecting twice to the same camera ? Is it expected ? Does the camera support multiple connections ?

        Interested in AI ? www.idiap.ch
        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

        1 Reply Last reply
        0

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved