Ask Your Question
0

Read video stream from VLC plyaer

asked 2017-03-21 08:27:04 -0600

bdm77 gravatar image

Hello!

I get a stream from the camera using the RTSP protocol.

    int main()
    {
     std::stringstream fmt;
fmt << "rtsp://" << "127.0.0.1" << ":" << "18554" << "/" << "streamer";

m_url = fmt.str();
    int count = 0;
double fps = 0.0;
bool isExit = false;
Mat frame;

std::string displayName_1 = "Display window_1";

namedWindow(displayName_1, WINDOW_NORMAL);// Create a window for display.   
resizeWindow(displayName_1, 400, 400);

do {
    std::cout << std::endl << " Try connection to camera: " << +m_url.c_str() << std::endl;
    VideoCapture cam(m_url.c_str());

    while (true)
    {
        count++;

        if (!cam.read(frame)) {
            printf(" Not get frames from camera %s\n", m_url.c_str());
            if (count >= 10) {
                count = 0; break;
            }
            continue;
        }

        if (frame.data) {
            imshow(displayName_1, frame);                   // Show our image inside it.            }
        else
        {
            printf("Failed to get frames from the camera!!! count %d of 10 \n", count);
            if (count == 10) {
                count = 0;
                break;
            }
        }

        if (cvWaitKey(10) == 27) {
            isExit = true;
            break;
        }

    }
} while (!isExit);
}

Works great.

Now I need to write a simulation of the camera.

In the VLC player, I read the video file and send it to the stream. (:sout=#rtp{sdp=rtsp://:18554/streamer} :sout-all :sout-keep)

When I try to read the stream, I get an error - "[rtsp @ 000002a02cead760] method SETUP failed: 461 Client error"

How can this problem be solved. Thank you!

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
1

answered 2017-03-21 08:52:16 -0600

bdm77 gravatar image

If I use command line ffmpeg -i rtsp://@127.0.0.1:18554/streamer -acodec copy -vcodec copy c:/events/abc.mp4 then it works fine.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2017-03-21 08:27:04 -0600

Seen: 3,576 times

Last updated: Mar 21 '17