Java OpenCV/JavaCV - Unable to read UDP video content

asked 2016-06-29 14:32:26 -0500

nick3185 gravatar image

I have a device that sends live video from a scene camera. The video is encoded into the h.264 compression format. The audio from is encoded into the mp3 compressions format. It is transmitted via UDP as mpeg-ts (MPEG transport stream) packets (188 bytes each).

I am able to vie the content by opening the following addess with VLC udp://@

However, I am unable to read that content with OpenCV using these lines

VideoCapture camera = new VideoCapture();"udp://@");

Mat frame = new Mat();;

Using the grab funtion with these lines:

boolean grab = false;
grab = camera.grab();

The grab variable remains false.

With JavaCV, I have the following lines:

FFmpegFrameGrabber grabber = new FFmpegFrameGrabber("udp://@");

and I get the following error

null: InvocationTargetException: Could not initialize class org.bytedeco.javacpp.avutil

Thanks in advance

edit retag flag offensive close merge delete


hmm, javacv is an unsupported, 3rd party effort. if you run into any trouble with that, we cannot help you.

berak gravatar imageberak ( 2016-06-29 20:49:05 -0500 )edit

for the Videocapture attempt, make sure you have opencv_ffmpeg.dll next to your app (or on the path)

berak gravatar imageberak ( 2016-06-30 00:36:39 -0500 )edit

Pretty sure it is. Using eclipse, under native library location I link to .../opencv/build/java/x64 which includes the dll file in ...\opencv\build\x64\vc11\bin

nick3185 gravatar imagenick3185 ( 2016-06-30 06:56:23 -0500 )edit

Which version of OpenCV are you using? While using VideoCapture to connect to an RTSP stream, I noticed that OpenCV 3.0.0 defaults to opening a UDP socket to transport video. Starting with OpenCV 3.1.0, it defaults to opening a TCP socket. That same modification is supposedly in OpenCV 2.4.11 and later. If you're using a version that defaults to TCP, OpenCV 3.0.0 or 2.4.10 might work for you.

victorft gravatar imagevictorft ( 2016-12-30 18:56:37 -0500 )edit