Ask Your Question

Revision history [back]

How to open a video stream

I am trying to open the video being streamed from Intel Edison which is written in node.js. ffmpeg is used to encode video to MPEG1 whereas jsmpeg is used to decode the video. The video is rendered onto canvas element in the web browser.

The coding as follow. I can't view the video in openCV.

int main()
{
VideoCapture vcap1;

Mat stream1; Mat grains(480,640,CV_8UC3,Scalar::all(0)); const string videoStreamAddress1 = "http://192.168.8.100:8082"; vcap1.set(CV_CAP_PROP_FOURCC, CV_FOURCC('P','I','M','1'));

if(!vcap1.open(videoStreamAddress1)) { cout << "Error opening video stream1" << endl; }
if(!vcap2.open(videoStreamAddress2)) { cout << "Error opening video stream2 " << endl; }

for(;;){
if(!vcap1.read(stream1)) { putText(grains, std::string("Stream not avilable....."), cv::Point(150,200), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, cv::Scalar(0,255,0,255)); imshow("Stream 1", grains); } else imshow("Stream 1", stream1);

if(waitKey(33) >= 0) break; }
return 0; }

How to open a video stream

I am trying to open the video being streamed from Intel Edison which is written in node.js. ffmpeg is used to encode video to MPEG1 whereas jsmpeg is used to decode the video. The video is rendered onto canvas element in the web browser.

The coding as follow. I can't view the video in openCV.

int main() 
{
VideoCapture vcap1;

vcap1; Mat stream1; Mat grains(480,640,CV_8UC3,Scalar::all(0)); const string videoStreamAddress1 = "http://192.168.8.100:8082"; vcap1.set(CV_CAP_PROP_FOURCC, CV_FOURCC('P','I','M','1'));

CV_FOURCC('P','I','M','1')); if(!vcap1.open(videoStreamAddress1)) { cout << "Error opening video stream1" << endl; }
if(!vcap2.open(videoStreamAddress2)) { cout << "Error opening video stream2 " << endl; }

} for(;;){
if(!vcap1.read(stream1)) { putText(grains, std::string("Stream not avilable....."), cv::Point(150,200), cv::FONT_HERSHEY_COMPLEX_SMALL, 1, cv::Scalar(0,255,0,255)); imshow("Stream 1", grains); } else imshow("Stream 1", stream1);

stream1); if(waitKey(33) >= 0) break; }
return 0; }

}