Getting RTSP stream with JavaCV library

I am currently trying to get an RTSP stream from an IP camera on my network so that I can apply facial recognition algorithms to frames (I am using the JavaCV library for this).

When I try to get an RTSP stream, I get an error depending on the method I was trying to use.

Here's the code that should work:

try {
    FFmpegFrameGrabber streamGrabber = new FFmpegFrameGrabber("rtsp://admin:12345@(ip)/ch1/main/av_stream");
    streamGrabber.setFormat("h264");
    streamGrabber.setFrameRate(30);
    streamGrabber.setImageWidth(getWidth());
    streamGrabber.setImageHeight(getHeight());
    streamGrabber.start();
} catch (Exception e) {
    e.printStackTrace();
}

      

This particular piece of code is giving me this error:

org.bytedeco.javacv.FrameGrabber$Exception: avformat_open_input() error -1330794744: Could not open input "rtsp://admin:12345@192.168.64.96/ch1/main/av_stream". (Has setFormat() been called?)
    at org.bytedeco.javacv.FFmpegFrameGrabber.startUnsafe(FFmpegFrameGrabber.java:393)
    at org.bytedeco.javacv.FFmpegFrameGrabber.start(FFmpegFrameGrabber.java:341)
    at main.FaceApplet.init(FaceApplet.java:87)
    at sun.applet.AppletPanel.run(AppletPanel.java:425)
    at java.lang.Thread.run(Thread.java:695)

      

I have tried:

  • OpenCVFrameGrabber is used instead - error says "Failed to create camera capture"

  • Using IPCameraFrameGrabber - http url required

  • Protocol change:

    • FTP: authentication failed

    • TCP: program hangs

    • UDP: authentication failed

What am I doing wrong, is it a code issue or a camera issue?

+3


source to share


1 answer


Refresh

I finally got it working ... the magic formula seems to be using FFMpeggrabber to get the stream ... to avoid the error, just don't set the video format with the function. The initializer code should look something like this:



streamGrabber = new FFmpegFrameGrabber("rtsp://admin:12345@(ip):554/live.sdp");
streamGrabber.setFrameRate(30);
streamGrabber.setImageWidth(getWidth());

try {
    streamGrabber.start();
} catch (FrameGrabber.Exception e) {
    e.printStackTrace();
}

      

0


source







All Articles