Read h264 stream from an IP camera

This forum is about all development around libVLC.
JCNeves
New Cone
New Cone
Posts: 1
Joined: 05 Oct 2014 15:20

Read h264 stream from an IP camera

Postby JCNeves » 05 Oct 2014 15:26

Currently, I am trying to use opencv to read a video from my Canon VB-H710F camera.

For this purpose I tried two different solutions:

SOLUTION 1: Read the stream from rtsp address

VideoCapture cam ("rtsp://root:camera@10.0.4.127/stream/profile1=u");

while(true)
cam >> frame;

In this case I am using opencv to directly read from a stream encoded with in H264 (profile1), however this yields the same problem reported here http://answers.opencv.org/question/3401 ... -decoding/
As suggested in the previous question, I tried to disable FFMPEG support in opencv installation, which solved the h264 decoding errors but raised other problem.
When accessing the stream with opencv, supported by gstreame, there is always a large delay associated.
With this solution I achieve 15 FPS but I have a delay of 5 seconds, which is not acceptable considering that I need a real time application.

SOLUTION 2: Read the frames from http address
while(true)
{
startTime=System.currentTimeMillis();

URL url = new URL("h t t p://[IP]/-wvhttp-01-/image.cgi");
URLConnection con = url.openConnection();
BufferedImage image = ImageIO.read(con.getInputStream());
showImage(image);
estimatedTime=System.currentTimeMillis()-startTime;
System.out.println(estimatedTime);
Thread.sleep(5);
}

This strategy simply grabs the frame from the url that the camera provides. The code is in Java but the results are the same in C++ with the curl library.
This solution avoids the delay of the first solution however it takes little more than 100 ms to grab each frame, which means that I can only achieve on average 10 FPS.

I would like to know how can I access the video at 15 FPS in real time using c++ or libvlc ?

Rémi Denis-Courmont
Developer
Developer
Posts: 15268
Joined: 07 Jun 2004 16:01
VLC version: master
Operating System: Linux
Contact:

Re: Read h264 stream from an IP camera

Postby Rémi Denis-Courmont » 05 Oct 2014 15:53

In general, LibVLC can of course reach 15 f/s, but in practice it depends on the hardware, the network and the computational complexity of your postprocessing...
Rémi Denis-Courmont
https://www.remlab.net/
Private messages soliciting support will be systematically discarded


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 53 guests