Search Unity

Video Live stream as a texture

Discussion in 'Audio & Video' started by DrRek, Jul 10, 2020.

  1. DrRek

    DrRek

    Joined:
    Apr 9, 2016
    Posts:
    7
    Hello guys,
    I've got an IP camera from which I can get a video stream (either in mjpeg or h264 format, using proper URLs)

    Is there any easy way (script or free plugin) to display the live stream inside my scene?
    I've searched for many solutions online but they either don't work or are outdated.
     
  2. unitybru

    unitybru

    Unity Technologies

    Joined:
    Jan 28, 2020
    Posts:
    225
    You can use Spout (Windows) or Syphon (macOS) to stream textures between different apps, including Unity.
    To go from IP camera -> Spout/Syphon -> Unity plane you need a Spout/Syphon sender app that can stream your camera to that protocol, and a receiver in Unity that catches it. I don't know of any such apps (webcam to Spout/Syphon sender) but they must exist.

    To receive the texture in Unity, use this:
    https://github.com/keijiro/KlakSpout
    https://github.com/keijiro/KlakSyphon
     
  3. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    the easiest is to, obviously, make the IP cam register in the system as a Webcam - you can then open it directly in Unity
    for that you will need direct support from the manufacturer - which is usually a problem for IP cams

    some support local http server - where you might connect directly e.g. from VideoPlayer -

    but overall IP cams are problematic in that you need to bring it in sane way outside Unity first
     
  4. DrRek

    DrRek

    Joined:
    Apr 9, 2016
    Posts:
    7
    I didn't mention I'm building an Android app, sorry. Adding an external pc to work with the data stream looks like overkill to me ;) It would only increase the software complexity

    Anyway thanks for the suggestion!
     
  5. DrRek

    DrRek

    Joined:
    Apr 9, 2016
    Posts:
    7
    Can you explain better what do you mean by HTTP server?

    My IP camera is simply a raspberry zero w with a camera module and I do have a webserver serving it, but the video player still doesn't seem to work. Am I doing something wrong?

    p.s. I'm building an Android app, so the webcam solution isn't viable
     
  6. r618

    r618

    Joined:
    Jan 19, 2009
    Posts:
    1,305
    Webcam is available on mobiles, but in this case more like isn't (meaning for IP cams, phone cameras more or less work with the class)
    If you have some webserver set up try opening it in something like VLC
    If that works then the video format isn't probably compatible with Unity VideoPlayer class
     
  7. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,438
  8. DrRek

    DrRek

    Joined:
    Apr 9, 2016
    Posts:
    7
    It does work on VLC the mjpeg


    Thanks but atm I don't have any budget to spend on this side project :(

    Anyway, I think I'll just implement my mjpeg receiver, it shouldn't be so difficult.
    I was hoping to find some h264 decoder just to have some video compression, but I guess I'll leave that for some future phase

    Thanks to all of you. I'll eventually post a link to how to do it once I'll manage to make it work.
     
  9. tenconmar

    tenconmar

    Joined:
    Mar 15, 2021
    Posts:
    29
    Anyone tried this with VR or HoloLens?