1

I have a IP CAMERA which it is a Raspberry PI with Motion installed. I want to get one frame when an event is triggered using C#. The programming code in C# is as follows:

string sourceURL = "http://192.168.1.12:8081";

HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
req.Credentials = new NetworkCredential("username", "pass");

WebResponse resp = req.GetResponse();
using (Stream output = File.Create("some_image.jpeg"))
using (Stream input = resp.GetResponseStream())
{
    input.CopyTo(output); //<-- the code stops here 
}

Please, does anybody have an idea?

  • 1
    _"In response to a GET request for a MJPEG file or stream, the server streams the sequence of JPEG frames over HTTP. A special mime-type content type multipart/x-mixed-replace;boundary= informs the client to expect several parts (frames) as an answer delimited by . This boundary name is expressly disclosed within the MIME-type declaration itself."_ (yeah, I know, Wikipedia...) => Try and find out what the boundary is, cut the jpeg out of the stream using that boundary. – Fildor Jan 23 '20 at 16:56
  • But if I remember correctly, there should also be an endpoint for requesting a still image ... – Fildor Jan 23 '20 at 16:57
  • why don't u just save the file in memory and then convert it? – Steve Jan 23 '20 at 16:59
  • 1
    see https://raspberrypi.stackexchange.com/questions/28234/take-snap-from-raspberry-pi-using-motion for action/snapshot – Wolfgang Fahl Jan 25 '20 at 05:30

0 Answers0