Ask Your Question

Revision history [back]

Unable to capture 2 recorded video streams simultaneously

I am able to capture (using cv::VideoCapture) 2 live video streams (or 1 live stream & 1 recorded stream) simultaneously using OpenCV C++ in Visual Studio.

But, I am unable to capture more than 1 recorded streams simultaneously.

My code is:

#include <iostream>

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/videoio.hpp"

using namespace std;

using namespace cv;

const string camera1_main_streamURL = "rtsp://(..........SOME URL............)";
const string camera2_main_streamURL = "rtsp://(..........SOME URL............)";

const string windowName1 = "Output Image";
const string windowName = "camera1 main streaming";
const string windowName2 = "camera2 main streaming";

int main(int argc, const char * argv[])

{

//create video capture object for camera1 and camera2

    cv::VideoCapture cam1_capture(camera1_main_streamURL, cv::CAP_FFMPEG);
    cv::VideoCapture cam2_capture(camera2_main_streamURL, cv::CAP_FFMPEG);

    if (!cam1_capture.isOpened())
{
    //Error
    std::cout << "Input error 1\n";
    return -2;
}

if (!cam2_capture.isOpened())
{
    //Error
    std::cout << "Input error 1\n";
    return -3;
}

while (true)
{
    // initialise the window for camera1 and camera2 streaming
    cv::namedWindow("camera1 main streaming", WINDOW_AUTOSIZE);
    cv::namedWindow("camera2 main stream", WINDOW_AUTOSIZE);

    //grab and retrieve each frames of the camera1 and camera2  sequentially 
    cv::Mat3b frame1;
    cam1_capture >> frame1;

    cv::Mat3b frame2;
    cam2_capture >> frame2;

    if (!cam1_capture.read(frame1))
    {
        //Error
        std::cout << "Input error 2\n";
        return -1;
    }

    if (!cam2_capture.read(frame2))
    {
        //Error
        std::cout << "Input error 2\n";
        return -1;
    }

    //display  both the frame 
    cv::imshow("camera1 main streaming", frame1);
    cv::imshow("camera2 main stream", frame2);


    if (cv::waitKey(1) >= 0) break;
    cv::waitKey(30);
    //press any key from keyboard to stop and save the video
}


cam1_capture.release();
cam2_capture.release();
return 0;

}

Output:

[rtsp @ 000000ea2bf8fc40] method DESCRIBE failed: 453 Not Enough Bandwidth Input error 1

Unable to capture 2 recorded video streams simultaneously

I am able to capture (using cv::VideoCapture) 2 live video streams (or 1 live stream & 1 recorded stream) simultaneously using OpenCV C++ in Visual Studio.

But, I am unable to capture more than 1 recorded streams simultaneously.

My code is:

 #include <iostream>

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc.hpp"
#include "opencv2/opencv.hpp"
#include "opencv2/videoio.hpp"

using `#include "opencv2/core/core.hpp"`<br/> `#include "opencv2/highgui/highgui.hpp"`<br/> `#include "opencv2/imgproc.hpp"`<br/> `#include "opencv2/opencv.hpp"`<br/> `#include "opencv2/videoio.hpp"`<br/> `using namespace std;

using std;` `using namespace cv;

const cv;` `const string camera1_main_streamURL = "rtsp://(..........SOME URL............)";
const URL............)";`<br/> `const string camera2_main_streamURL = "rtsp://(..........SOME URL............)";

const URL............)";` `const string windowName1 = "Output Image";
const Image";`<br/> `const string windowName = "camera1 main streaming";
const streaming";`<br/> `const string windowName2 = "camera2 main streaming";

streaming";`<br/> int main(int argc, const char * argv[])

{

argv[])

{

    //create video capture object for camera1 and camera2

     cv::VideoCapture cam1_capture(camera1_main_streamURL, cv::CAP_FFMPEG);
     cv::VideoCapture cam2_capture(camera2_main_streamURL, cv::CAP_FFMPEG);

     if (!cam1_capture.isOpened())
 {
     //Error
     std::cout << "Input error 1\n";
     return -2;
 }

 if (!cam2_capture.isOpened())
 {
     //Error
     std::cout << "Input error 1\n";
     return -3;
 }

 while (true)
 {
     // initialise the window for camera1 and camera2 streaming
     cv::namedWindow("camera1 main streaming", WINDOW_AUTOSIZE);
     cv::namedWindow("camera2 main stream", WINDOW_AUTOSIZE);

     //grab and retrieve each frames of the camera1 and camera2  sequentially 
     cv::Mat3b frame1;
     cam1_capture >> frame1;

     cv::Mat3b frame2;
     cam2_capture >> frame2;

     if (!cam1_capture.read(frame1))
     {
         //Error
         std::cout << "Input error 2\n";
         return -1;
     }

     if (!cam2_capture.read(frame2))
     {
         //Error
         std::cout << "Input error 2\n";
         return -1;
     }

     //display  both the frame 
     cv::imshow("camera1 main streaming", frame1);
     cv::imshow("camera2 main stream", frame2);


     if (cv::waitKey(1) >= 0) break;
     cv::waitKey(30);
     //press any key from keyboard to stop and save the video
 }


 cam1_capture.release();
 cam2_capture.release();
 return 0;

}

}

Output:

[rtsp @ 000000ea2bf8fc40] method DESCRIBE failed: 453 Not Enough Bandwidth Input error 1

Unable to capture 2 recorded video streams simultaneously

I am able to capture (using cv::VideoCapture) 2 live video streams (or 1 live stream & 1 recorded stream) simultaneously using OpenCV C++ in Visual Studio.

But, I am unable to capture more than 1 recorded streams simultaneously.

My code is:

   #include <iostream>
`#include "opencv2/core/core.hpp"`<br/>
`#include "opencv2/highgui/highgui.hpp"`<br/>
`#include "opencv2/imgproc.hpp"`<br/>
`#include "opencv2/opencv.hpp"`<br/>
`#include "opencv2/videoio.hpp"`<br/>

`using namespace std;`

`using namespace cv;`

`const string camera1_main_streamURL = "rtsp://(..........SOME URL............)";`<br/>
`const string camera2_main_streamURL = "rtsp://(..........SOME URL............)";`

`const string windowName1 = "Output Image";`<br/>
`const string windowName = "camera1 main streaming";`<br/>
`const string windowName2 = "camera2 main streaming";`<br/>


int main(int argc, const char * argv[])

{

    //create video capture object for camera1 and camera2

        cv::VideoCapture cam1_capture(camera1_main_streamURL, cv::CAP_FFMPEG);
        cv::VideoCapture cam2_capture(camera2_main_streamURL, cv::CAP_FFMPEG);

        if (!cam1_capture.isOpened())
    {
        //Error
        std::cout << "Input error 1\n";
        return -2;
    }

    if (!cam2_capture.isOpened())
    {
        //Error
        std::cout << "Input error 1\n";
        return -3;
    }

    while (true)
    {
        // initialise the window for camera1 and camera2 streaming
        cv::namedWindow("camera1 main streaming", WINDOW_AUTOSIZE);
        cv::namedWindow("camera2 main stream", WINDOW_AUTOSIZE);

        //grab and retrieve each frames of the camera1 and camera2  sequentially 
        cv::Mat3b frame1;
        cam1_capture >> frame1;

        cv::Mat3b frame2;
        cam2_capture >> frame2;

        if (!cam1_capture.read(frame1))
        {
            //Error
            std::cout << "Input error 2\n";
            return -1;
        }

        if (!cam2_capture.read(frame2))
        {
            //Error
            std::cout << "Input error 2\n";
            return -1;
        }

        //display  both the frame 
        cv::imshow("camera1 main streaming", frame1);
        cv::imshow("camera2 main stream", frame2);


        if (cv::waitKey(1) >= 0) break;
        cv::waitKey(30);
        //press any key from keyboard to stop and save the video
    }


    cam1_capture.release();
    cam2_capture.release();
    return 0;

}

Output:

[rtsp @ 000000ea2bf8fc40] method DESCRIBE failed: 453 Not Enough Bandwidth
Input error 1

1