Delay to load and delayed stream
Im running this code:
#include <iostream>
#include <sstream>
#include <ctime>
#include <string>
#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
using namespace cv;
using namespace std;
int main()
{
//create matrix for storage
Mat feed, feed2;
//initialize capture
VideoCapture cap, cap2;
cap.open("http://192.168.1.128/videostream.asf?user=admin&pwd=");
cap2.open("http://192.168.1.110/webcam.mjpeg");
// check if we succeeded
if (!cap.isOpened()){
cerr << "Failed to open video capture" << std::endl;
cout << "cannot open camera";
return -1;
}
if (!cap2.isOpened()){
cerr << "Failed to open video capture" << std::endl;
cout << "cannot open camera";
return -1;
}
//create window to show image
namedWindow("VIDEO", 1);
//loop
while (true){
//copy webcam stream to image
cap >> feed;
cap2 >> feed2;
resize(feed, feed, Size(1270, 700), 0, 0, INTER_CUBIC);
resize(feed2, feed2, Size(320, 170), 0, 0, INTER_CUBIC);
feed2.copyTo(feed(cv::Rect(874,463,feed2.cols, feed2.rows)));
//small_image.copyTo(big_image(cv::Rect(x,y,small_image.cols, small_image.rows)));
//webcamstream
imshow("VIDEO", feed);
//exit it key pressed
if (waitKey(30) >= 0){
break;
}
//delay33ms
waitKey(10);
//
}//endloop
}//main
I've got a Raspberry pi with a USB composite capturer running FFMPEG on server with the following setup:
/etc/ffserver.conf
Port 80
BindAddress 0.0.0.0
MaxClients 10
MaxBandwidth 50000
NoDaemon
<Feed webcam.ffm>
file /tmp/webcam.ffm
FileMaxSize 10M
</Feed>
<Stream webcam.mjpeg>
Feed webcam.ffm
#Format mpjpeg
Format avi
VideoSize 320x170
VideoBufferSize 5
VideoFrameRate 10
VideoBitRate 500
VideoQMin 1
VideoQMax 10
</Stream>
and the command:
ffserver -f /etc/ffserver.conf & ffmpeg -v verbose -r 10 -s 320x170 -f video4lilinux2 -i /dev/video0 http://localhost/webcam.ffm
When I use only one of the stream I can get delays or should I say I have a delay of 5 seconds which is acceptable, but when I have both stream I get a 20 seconds delay. I have looked around and there seam to be some bugs but looks like 2 years ago.
Is there any way to know what could be causing this? and how could I solve it? reducing the size buffer? I've noticed the the one of the stream from an IP camera come without delay
The IPCam creating the issues is a USB/Composite capture on a Raspberry Pi with FFMPEG, I think FFMPEG is the source of the issue.
I'm going to re-edit my post later today, I've done some progress, looks like the ffmpeg server was properly setup or there was better ways of setting it up. Im going to re-edit my post later my program is still hanging and im getting a 20second delay on that stream...
I've edited with progress and new findings, changed the title as it;s not hanging anymore... xP