Read video stream from VLC plyaer
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!