Java OpenCV/JavaCV - Unable to read UDP video content
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://@192.168.1.137:13007
However, I am unable to read that content with OpenCV using these lines
VideoCapture camera = new VideoCapture();
camera.open("udp://@192.168.1.137:13007");
Mat frame = new Mat();
camera.read(frame);
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://@192.168.1.137:13007");
grabber.start();
and I get the following error
null: InvocationTargetException: Could not initialize class org.bytedeco.javacpp.avutil
Thanks in advance
hmm, javacv is an unsupported, 3rd party effort. if you run into any trouble with that, we cannot help you.
for the Videocapture attempt, make sure you have opencv_ffmpeg.dll next to your app (or on the path)
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
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.