I am currently trying to obtain an RTSP stream from an IP camera on my network so that I can apply facial recognition algorithms to the frames (I am using the JavaCV library for this).
When I attempt to obtain the RTSP stream, I start getting an error depending upon the method that I tried to use.
Here is 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();
}
That particular piece of code gives me this error:
org.bytedeco.javacv.FrameGrabber$Exception: avformat_open_input() error -1330794744: Could not open input "rtsp://admin:[email protected]/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:
Using OpenCVFrameGrabber instead - error says "Could not create camera capture"
Using IPCameraFrameGrabber - requires http url
Changing Protocol:
FTP: Authentication Failed
TCP: Freezes the program
UDP: Authentication Failed
What am I doing wrong, is this a code issue or a camera issue?
Update
I Finally got it working... the magic formula seems to be using the FFMpeggrabber to obtain a stream... to avoid the error, just don't set the video format using the function. Initializer code should look something like this: