-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I can't display image when IP Camera Mjpeg use /snapshot.cgi or /videostream.cgi (issues detailed) #255
Comments
Hi @henriquem, The easiest would be to enable wire log from http client (it downloads the image) to see what is happening under the hood of IP camera driver. Wire log will print whole both HTTP request and response, so you can see how it differs from the original request from Firefox. To enable wire log:
<configuration scan="true" scanPeriod="30 seconds">
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
<layout class="ch.qos.logback.classic.PatternLayout">
<Pattern>%d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n</Pattern>
</layout>
</appender>
<logger name="org.apache.http.wire" level="INFO" />
<logger name="org.apache.http.headers" level="DEBUG" />
<logger name="com.github.sarxos.webcam.ds.ipcam" level="debug" />
<root level="debug">
<appender-ref ref="STDOUT" />
</root>
</configuration>
WebcamLogConfigurator.configure("logback.xml"); After your application is executed you should see what requests are being send by IP camera driver and what is being received, e.g. in case of
If the camera needs authentication (and what kind), you will most probably see this in the headers received on the GET request. Now your goal is to verify what is being send when you stream MJPEG using Firefox (don't use Chrome - support for MJPEG on GET from URL bar has been deprecated). Simply use MJPEG URL and put it in browser's URL bar. Before you hit the enter run the browser console to observe the web traffic (rightclick somewhere and choose Inspect element (Q)). In the Network tab you can check all headers which are send by Firefox and cookies, if any. If you track down what header/cookie is missing in wire log when you compare with log from Firefox console, you will most likely find what is wrong. Maybe webcam needs some other kind of authentication (the build in auth method is Basic Auth). Just FYI, if you have a possibility to expose your webcam on the internet I can access it, and verify this on my own. |
Thanks Sarxos, for good explanation |
Hi sarxos, It is solved !
if (ct.getValue().startsWith("image/")) {
In this way works fine ! |
Sarxos, if you want to test the camera ip public is :
My doubt: So, the content from videostream.cgi is an Header ( source code use: Header ct = entity.getContentType();) So, by IpCamMjpeg not is possible display images from "/videostream.cgi" Do you know some solution for improve the shapshot.cgi ? Thanks! |
Hi @henriquem, I just came back from the vacation, so please forgive me for no response in this time frame. To make this clear:
What is the difference?
I tested above URL (MJPEG i.e. public class MjpegPushExample {
/**
* Remember to add IP camera driver JAR to the application classpath!
* Otherwise you will not be able to use IP camera driver features. Driver
* has to be set at the very beginning, before any webcam-capture related
* method is being invoked.
*/
static {
Webcam.setDriver(new IpCamDriver());
}
public static void main(String[] args) throws MalformedURLException {
// use this logback.xml only if file exists
WebcamLogConfigurator.configure("src/examples/resources/logback.xml");
String name = "Test #255";
String url = "http://ce3014.myfoscam.org:20054/videostream.cgi";
IpCamMode mode = IpCamMode.PUSH;
IpCamAuth auth = new IpCamAuth("user", "user");
IpCamDeviceRegistry.register(name, url, mode, auth);
WebcamPanel panel = new WebcamPanel(Webcam.getWebcams().get(0));
panel.setFPSLimit(1);
JFrame f = new JFrame("Test #255");
f.add(panel);
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} And I had no issues after it's run: For the authenticated static JPEG image, i.e. public class MjpegPushExample {
static {
Webcam.setDriver(new IpCamDriver());
}
public static void main(String[] args) throws MalformedURLException {
// use only if you have this logback.xml file
WebcamLogConfigurator.configure("src/examples/resources/logback.xml");
String name = "Test #255";
String url = "http://ce3014.myfoscam.org:20054/snapshot.cgi";
IpCamMode mode = IpCamMode.PULL;
IpCamAuth auth = new IpCamAuth("user", "user");
IpCamDeviceRegistry.register(name, url, mode, auth);
WebcamPanel panel = new WebcamPanel(Webcam.getWebcams().get(0));
panel.setFPSLimit(1);
JFrame f = new JFrame("Test #255");
f.add(panel);
f.pack();
f.setVisible(true);
f.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
} Also working well, but FPS rate is damn smaller (obviously) because of the way of how PULL work (multiple requests vs one in push), so for higher FPS PUSH has to be used with Therefore, in regards to your comment:
I cannot agree with this statement since I proved empirically that fetching images is possible in both cases (PULL and PUSH). |
Hello!
Please Help me in this situation:
I'm always use ip camera avaliable of internet for test, For example:
this example works fine very well!
But when I bought an ip camera ( with support MJPEG)
The configuration has few differents.
For example, when i access by browser, pressing the key F5 ( refresh) the images is captured very good!
I use the Url works:
http://10.0.0.103:81/snapshot.cgi?loginuse=admin&loginpas=
I saw more details of network using F12 from browser google Chrome, you can see it:
But when I will use in framework I faced this problem:
I tried with authentication also:
new IpCamAuth("admin","")
and Url
http://10.0.0.103:81/videostream.cgi
// not worksall attempts is occured Exception:
Using /snapshot.cgi
Do you know what I can do ?
Thanks!
The text was updated successfully, but these errors were encountered: