'Can't catch my IP Camera stream URL but other IP Camera stream URLs works
I am using the below code successfully to stream the URL of a public IP web camera.
Now, I have set up my own IP Camera and I am now trying to catch this feed but are not successfull.
I am not sure if I should share the correct URL because it can be overload if everyone is checking.
However, - the exact format of the URL is this which works in Chrome where I can see the feed:
http://admin:[email protected]:1024/web/admin.html (not the real IP)
The feed in chrome looks like this which is the IP Camera software
I am then trying to catch ONLY the image stream itself with below code which I am not successful with. I have tried below with no success at all. Nothing appears in the image control:
http://admin:[email protected]:1024/web/admin.html
http://admin:[email protected]:1024
http://79.123.101.121:1024
As seen I add username and password which are: admin and admin which is needed to see the stream.
What could be the problem for this?
(I am using the library: "Emgu.CV" version v4.1.1.3497 which exist in the Nuget that can be installed)
using Emgu.CV;
using Emgu.CV.UI;
using Emgu.CV.Structure;
private VideoCapture _capture = null;
private bool _captureInProgress;
Emgu.CV.UI.ImageBox imageBox = new Emgu.CV.UI.ImageBox();
public Form1()
{
InitializeComponent();
imageBox.Width = 700;
imageBox.Height = 500;
panel19.Controls.Add(imageBox);
CvInvoke.UseOpenCL = false;
try
{
_capture = new VideoCapture("http://77.243.103.105:8081/mjpg/video.mjpg");
_capture.ImageGrabbed += ProcessFrame;
}
catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); }
}
private void button1_Click(object sender, EventArgs e)
{
if (_capture == null)
{
try
{
_capture = new VideoCapture();
}
catch (NullReferenceException excpt) { MessageBox.Show(excpt.Message); }
}
if (_capture != null)
{
if (_captureInProgress)
{
button1.Text = "Start!"; //if camera is getting frames then stop the capture and set button Text "Start" for resuming capture
Application.Idle -= ProcessFrame;
}
else
{
button1.Text = "Stop"; //if camera is NOT getting frames then start the capture and set button Text to "Stop" for pausing capture
Application.Idle += ProcessFrame;
}
_captureInProgress = !_captureInProgress;
}
}
Mat frame = new Mat();
private void ProcessFrame(object sender, EventArgs arg)
{
//_capture.Retrieve(frame, 0); //(1st try)
_capture.Read(frame); //This calls Grab() as grabbing a frame and then Retrieve(); (2nd try)
imageBox.Image = frame; //line 2
}
EDIT:
I used wireshark when I entered the IP Camera in Chrome browser to sniff what is going on. I have changed the IP in the below so not everyone is looking as I am developing on the camera:
This is the information I get:
GET /web/cgi-bin/hi3510/param.cgi?cmd=getvencattr&-chn=11&cmd=getvencattr&-chn=12&cmd=getsetupflag&cmd=getaudioflag&cmd=getrtmpattr HTTP/1.1
Host: 79.129.110.182:1024
Connection: keep-alive
Authorization: Basic YWRtaW46YWRtaW4=
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.97 Safari/537.36
Accept: */*
Referer: http://79.129.110.182:1024/web/mainpage.html
Accept-Encoding: gzip, deflate
Accept-Language: sv-SE,sv;q=0.9,en-US;q=0.8,en;q=0.7
Cookie: streamselect=1; cookmun=1; language0=1
HTTP/1.1 200 OK
Server: Hipcam
Cache-Control: no-cache
Content-Type:text/html
Connection: close
Content-Length: 379
Then If I build an URL from above info like this:
http://79.129.110.182:1024/web/cgi-bin/hi3510/param.cgi?cmd=getvencattr&-chn=11&cmd=getvencattr&-chn=12&cmd=getsetupflag&cmd=getaudioflag&cmd=getrtmpattr
I get this result in chrome which actually are the settings for the IP Camera:
var bps_1="1536"; var fps_1="25"; var gop_1="50"; var brmode_1="1"; var imagegrade_1="4"; var width_1="1280"; var height_1="720"; var bps_2="448"; var fps_2="5"; var gop_2="50"; var brmode_2="1"; var imagegrade_2="2"; var width_2="640"; var height_2="352"; var name0="admin"; var password0="admin"; var authLevel0="15"; var audioflag="1"; var rtmpport="1935";
Solution 1:[1]
For newer cameras, try the following to get a stream:
- rtsp://default:@192.168.xx.xx:554/11
- http://default:@192.168.xx.xx/livestream.cgi?stream=2&action=play&media=video_audio_data
You can also make your own webpage and add a video canvas object, pass it as a parameter to libede265.js (found on camera, http://<your_ip>/js/libde265.js).
I'm also making a chrome extension to make this web interface better. Right now it's just fullscreen video and PTZ control via keyboard. Lots more to come.
I call it - "POS IP Cam"
<head>
<script src="<ip>/js/libde265.js" type="text/javascript"></script>
<script type="text/javascript">
window.addEventListener("load", function () {
let ip = "<your_ip>";
let httpport = "80";
let stream = 11; //11 or 12
let username = "<your_username>";
let password = "<your_password>";
let video_canvas = document.getElementById("video_canvas");
player = new libde265.RawPlayer(video_canvas);
player.playvideo(ip, httpport, stream, username, password);
});
</script>
</head>
<body>
<canvas id="video_canvas"></canvas>
</body>
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | chris mclellen |
