Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

network stream udp

I want to process and display a network rtsp stream that is created from a raspberry camera. I have this code:

#include <iostream>
#include <functional>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main(int argc, char** argv) {

    cv::VideoCapture * stream = new cv::VideoCapture("rtsp://192.168.55.151:8554/");
    if (!stream->isOpened()) return -1;

    cv::namedWindow("rtsp_stream", CV_WINDOW_AUTOSIZE);
    cv::Mat frame;

    while (true) {

        if (!stream->read(frame)) return -1;

        cv::imshow("rtsp_stream", frame);
        cv::waitKey(15);
    }

    return 1;
}

When the stream is not live, the execution of this results in:

[tcp @ 0xa12480] Connection to tcp://192.168.55.151:8554?timeout=0 failed: Connection refused

Which means that the stream tries to connect with tcp. When the stream is live, the execution results in:

 [rtsp @ 0xb07960] method SETUP failed: 461 Client error

From internet research i found that the problem may be that the stream uses udp. If i change the URL to:

"udp://192.168.55.151:8554/"

Then the execution freezes in the cv::VideoCapture("udp://192.168.55.151:8554/"); How can i solve my problem?

network stream udp

I want to process and display a network rtsp stream that is created from a raspberry camera. I have this code:

#include <iostream>
#include <functional>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main(int argc, char** argv) {

    cv::VideoCapture * stream = new cv::VideoCapture("rtsp://192.168.55.151:8554/");
    if (!stream->isOpened()) return -1;

    cv::namedWindow("rtsp_stream", CV_WINDOW_AUTOSIZE);
    cv::Mat frame;

    while (true) {

        if (!stream->read(frame)) return -1;

        cv::imshow("rtsp_stream", frame);
        cv::waitKey(15);
    }

    return 1;
}

When the stream is not live, the execution of this results in:

[tcp @ 0xa12480] Connection to tcp://192.168.55.151:8554?timeout=0 failed: Connection refused

Which means that the stream tries to connect with tcp. When the stream is live, the execution results in:

 [rtsp @ 0xb07960] method SETUP failed: 461 Client error

From internet research i found that the problem may be that the stream uses udp. If i change the URL to:

"udp://192.168.55.151:8554/"

Then the execution freezes in the cv::VideoCapture("udp://192.168.55.151:8554/"); How can i solve my problem?

VLC is able to open the stream.

network stream udp

I want to process and display a network rtsp stream that is created from a raspberry camera. I have this code:

#include <iostream>
#include <functional>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main(int argc, char** argv) {

    cv::VideoCapture * stream = new cv::VideoCapture("rtsp://192.168.55.151:8554/");
    if (!stream->isOpened()) return -1;

    cv::namedWindow("rtsp_stream", CV_WINDOW_AUTOSIZE);
    cv::Mat frame;

    while (true) {

        if (!stream->read(frame)) return -1;

        cv::imshow("rtsp_stream", frame);
        cv::waitKey(15);
    }

    return 1;
}

When the stream is not live, the execution of this results in:

[tcp @ 0xa12480] Connection to tcp://192.168.55.151:8554?timeout=0 failed: Connection refused

Which means that the stream tries to connect with tcp. When the stream is live, the execution results in:

 [rtsp @ 0xb07960] method SETUP failed: 461 Client error

From internet research i found that the problem may be that the stream uses udp. If i change the URL to:

"udp://192.168.55.151:8554/"

Then the execution freezes in the cv::VideoCapture("udp://192.168.55.151:8554/"); How can i solve my problem?

Edit 1: VLC is able to open the stream.stream. Edit 2: As i am given to understand, ffmpeg is used to decode the stream. When i run:

ffmpeg -rtsp_transport udp -i rtsp://192.168.55.151:8554/ -t 5 test.mpg

the stream decoding and saving is successful. So how can i specify the lower level protocol to be udp?

network stream udp

I want to process and display a network rtsp stream that is created from a raspberry camera. I have this code:

#include <iostream>
#include <functional>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main(int argc, char** argv) {

    cv::VideoCapture * stream = new cv::VideoCapture("rtsp://192.168.55.151:8554/");
    if (!stream->isOpened()) return -1;

    cv::namedWindow("rtsp_stream", CV_WINDOW_AUTOSIZE);
    cv::Mat frame;

    while (true) {

        if (!stream->read(frame)) return -1;

        cv::imshow("rtsp_stream", frame);
        cv::waitKey(15);
    }

    return 1;
}

When the stream is not live, the execution of this results in:

[tcp @ 0xa12480] Connection to tcp://192.168.55.151:8554?timeout=0 failed: Connection refused

Which means that the stream tries to connect with tcp. When the stream is live, the execution results in:

 [rtsp @ 0xb07960] method SETUP failed: 461 Client error

From internet research i found that the problem may be that the stream uses udp. If i change the URL to:

"udp://192.168.55.151:8554/"

Then the execution freezes in the cv::VideoCapture("udp://192.168.55.151:8554/"); How can i solve my problem?

Edit 1: VLC is able to open the stream. stream.

Edit 2: As i am given to understand, ffmpeg is used to decode the stream. When i run:

ffmpeg -rtsp_transport udp -i rtsp://192.168.55.151:8554/ -t 5 test.mpg

the stream decoding and saving is successful. So how can i specify the lower level protocol to be udp?

network stream udp

I want to process and display a network rtsp stream that is created from a raspberry camera. I have this code:

#include <iostream>
#include <functional>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main(int argc, char** argv) {

    cv::VideoCapture * stream = new cv::VideoCapture("rtsp://192.168.55.151:8554/");
    if (!stream->isOpened()) return -1;

    cv::namedWindow("rtsp_stream", CV_WINDOW_AUTOSIZE);
    cv::Mat frame;

    while (true) {

        if (!stream->read(frame)) return -1;

        cv::imshow("rtsp_stream", frame);
        cv::waitKey(15);
    }

    return 1;
}

When the stream is not live, the execution of this results in:

[tcp @ 0xa12480] Connection to tcp://192.168.55.151:8554?timeout=0 failed: Connection refused

Which means that the stream tries to connect with tcp. When the stream is live, the execution results in:

 [rtsp @ 0xb07960] method SETUP failed: 461 Client error

From internet research i found that the problem may be that the stream uses udp. If i change the URL to:

"udp://192.168.55.151:8554/"

Then the execution freezes in the cv::VideoCapture("udp://192.168.55.151:8554/"); How can i solve my problem?

Edit 1: VLC is able to open the stream.

Edit 2: As i am given to understand, ffmpeg is used to decode the stream. When i run:

ffmpeg -rtsp_transport udp -i rtsp://192.168.55.151:8554/ -t 5 test.mpg

the stream decoding and saving is successful. So how can i specify the lower level protocol to be udp?

Edit 3: If i use the ffmpeg command with tcp insted of udp, i get the same error with the c++ code, 461 client error

network stream udp

I want to process and display a network rtsp stream that is created from a raspberry camera. I have this code:

#include <iostream>
#include <functional>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>

int main(int argc, char** argv) {

    cv::VideoCapture * stream = new cv::VideoCapture("rtsp://192.168.55.151:8554/");
    if (!stream->isOpened()) return -1;

    cv::namedWindow("rtsp_stream", CV_WINDOW_AUTOSIZE);
    cv::Mat frame;

    while (true) {

        if (!stream->read(frame)) return -1;

        cv::imshow("rtsp_stream", frame);
        cv::waitKey(15);
    }

    return 1;
}

When the stream is not live, the execution of this results in:

[tcp @ 0xa12480] Connection to tcp://192.168.55.151:8554?timeout=0 failed: Connection refused

Which means that the stream tries to connect with tcp. When the stream is live, the execution results in:

 [rtsp @ 0xb07960] method SETUP failed: 461 Client error

From internet research i found that the problem may be that the stream uses udp. If i change the URL to:

"udp://192.168.55.151:8554/"

Then the execution freezes in the cv::VideoCapture("udp://192.168.55.151:8554/"); How can i solve my problem?

Edit 1: VLC is able to open the stream.

Edit 2: As i am given to understand, ffmpeg is used to decode the stream. When i run:

ffmpeg -rtsp_transport udp -i rtsp://192.168.55.151:8554/ -t 5 test.mpg

the stream decoding and saving is successful. So how can i specify the lower level protocol to be udp?

Edit 3: If i use the ffmpeg command with tcp insted instead of udp, i get the same error with the c++ code, 461 client error