HTTP Video Stream with (IPC-EBW81230 12MP Panoramic Network IR Fisheye Camera)

DanielReal

n3wb
Joined
Nov 12, 2019
Messages
3
Reaction score
0
Location
New York
Hi,

I'm trying to stream the main video feed of my new camera (IPC-EBW81230 12MP Panoramic Network IR Fisheye Camera)

I want to stream in the game engine Unity.

I was able to get the stream into OBS Viewer software by using the rtsp protocol with the following URL:
rtsp:/admin:<password>@192.168.0.50:554/

But I need the HTTP equivalent to get that feed into Unity. I already have the

I have tried the following url with no luck:
http://admin:<password>@192.168.0.50/

It returns me no bytes of information and stops...

I couldn't find any doc on that...

I'm using this code to get the stream:

C#:
using UnityEngine;
using System.Collections;
using System;
using System.Net;
using System.IO;

public class NetworkCamera : MonoBehaviour {

   

    public string sourceURL = "http://192.168.0.50";
    private Texture2D texture;
    private Stream stream;
    private MeshRenderer frame;    /Mesh for displaying video

    private void Start() {
        frame = GetComponent<MeshRenderer>();
        GetVideo();
    }

    public void GetVideo() {
        texture = new Texture2D(2, 2);
        / create HTTP request
        HttpWebRequest req = (HttpWebRequest)WebRequest.Create(sourceURL);
        /Optional (if authorization is Digest)
        req.Credentials = new NetworkCredential("admin", "<password>");
        / get response
        WebResponse resp = req.GetResponse();
        / get response stream
        stream = resp.GetResponseStream();
        StartCoroutine(GetFrame());
    }

    IEnumerator GetFrame() {
        Byte[] JpegData = new Byte[100000];

        while (true) {
            int bytesToRead = FindLength(stream);
            print(bytesToRead);
            if (bytesToRead == -1) {
                print("End of stream");
                yield break;
            }

            int leftToRead = bytesToRead;

            while (leftToRead > 0) {
                leftToRead -= stream.Read(JpegData, bytesToRead - leftToRead, leftToRead);
                yield return null;
            }

            MemoryStream ms = new MemoryStream(JpegData, 0, bytesToRead, false, true);

            texture.LoadImage(ms.GetBuffer());
            frame.material.mainTexture = texture;
            stream.ReadByte(); / CR after bytes
            stream.ReadByte(); / LF after bytes
        }
    }

    int FindLength(Stream stream) {
        int b;
        string line = "";
        int result = -1;
        bool atEOL = false;

        while ((b = stream.ReadByte()) != -1) {
            if (b == 10) continue; / ignore LF char
            if (b == 13) { / CR
                if (atEOL) {  / two blank lines means end of header
                    stream.ReadByte(); / eat last LF
                    return result;
                }
                if (line.StartsWith("Content-Length:")) {
                    result = Convert.ToInt32(line.Substring("Content-Length:".Length).Trim());
                } else {
                    line = "";
                }
                atEOL = true;
            } else {
                atEOL = false;
                line += (char)b;
            }
        }
        return -1;
    }
}
Anyone has an idea?

Cheers,
 
Last edited:

Grn1z

Getting the hang of it
Joined
Aug 26, 2019
Messages
88
Reaction score
46
Location
Michigan
I am not sure this is more bi question. But I think it's like this. The url is rtsp:/ip:554/cam/realmonitor?channel=1&subtype=0&unicast=true&proto=Onvif

I am not sure tho.
 

DanielReal

n3wb
Joined
Nov 12, 2019
Messages
3
Reaction score
0
Location
New York
Hi,

I'm actually already able to get the streaming feed using the rtsp protocol. What I'm looking for is a similar request leveraging the HTTP protocol.
 

TonyR

IPCT Contributor
Joined
Jul 15, 2014
Messages
16,443
Reaction score
38,162
Location
Alabama
Hi,

I'm actually already able to get the streaming feed using the rtsp protocol. What I'm looking for is a similar request leveraging the HTTP protocol.
Try this:

Code:
http://user:password@Camera-IP/cgi-bin/mjpg/video.cgi?channel=1&subtype=0
or this:

Code:
http://Camera-IP/cgi-bin/mjpg/video.cgi?channel=1&subtype=0
 

DanielReal

n3wb
Joined
Nov 12, 2019
Messages
3
Reaction score
0
Location
New York
Thank you for your response! I'm actually returning the camera back to China since the latency of 3 seconds is a deal breaker for me.
 
Top