Git Product home page Git Product logo

Comments (7)

lbr38 avatar lbr38 commented on June 28, 2024 1

Hello

Local devices are not supported for now but this is something I'm working on. I'll let you know when it's supported.

from motion-ui.

lbr38 avatar lbr38 commented on June 28, 2024

So I don't think it's easily possible to handle the local camera; at least, I tried with code, and I wasn't successful.

The issue with the local camera is that the device (usually /dev/video0) cannot be directly displayed in the browser. You need to go through a streaming server (I recommend ustreamer) that will capture the camera's stream and broadcast it in MJPEG format.

Good news is that ustreamer is available as a docker container, here is how to set it up easily:

  1. Start by destroying the current motionui container (we'll recreate it afterward):
docker rm -f motionui
  1. Create a dedicated docker network for the motionui and ustreamer containers. This network will allow the containers to communicate with each other:
docker network create --driver bridge motionui-network
  1. Create the ustreamer container by adapting the resolution, fps and quality parameters according to your needs.
    Here, I'm sharing the /dev/video0 device (local camera) with the container (normally this will also be your device) and I'm integrating the container into the motionui-network.
docker run -d --restart always --network motionui-network --name ustreamer \
    --device /dev/video0:/dev/video0 \
    pikvm/ustreamer:latest \
    --resolution 1280x720 \
    --desired-fps 25 \
    --quality 95 \
    --format MJPEG \
    --device-timeout 2 \
    --device-error-delay 1
  1. Recreate the motionui container and also integrate it into the motionui-network (adapt the FQDN parameter to your needs):
docker run -d --restart always --network motionui-network --name motionui \
       -e FQDN=motionui.example.com \
       -p 8080:8080 \
       -v /etc/localtime:/etc/localtime:ro \
       -v /var/lib/docker/volumes/motionui-data:/var/lib/motionui \
       -v /var/lib/docker/volumes/motionui-captures:/var/lib/motion \
       lbr38/motionui:latest
  1. Check that the containers are running:
docker ps
  1. You can also check that both containers are in the same network:
docker network inspect motionui-network
  1. Now you can add the camera to motion-UI web interface by specifying the URL of the stream http://ustreamer:8080/stream and specifying the same resolution as you did for the ustreamer container.

image

I tested this setup locally with my laptop's camera, and it works fine.

Tell me if this works for you and I'll add it to the documentation as the official way to use a local camera.

More info on ustreamer: https://github.com/pikvm/ustreamer

from motion-ui.

samuk avatar samuk commented on June 28, 2024

Thanks. I'm slightly confused as I thought that was the point of Motion? https://raspberry-valley.azurewebsites.net/Streaming-Video-with-Motion/

I'll investigate ustreamer as an alternative though. Thanks for the writeup.

from motion-ui.

lbr38 avatar lbr38 commented on June 28, 2024

You are right, but using the motion service for streaming would require the motion service to run continuously to obtain the real-time image (on the stream page).
And if the motion service runs continuously, it includes continuous motion detection. I want to give the user the choice to view the stream in real-time without necessarily activating motion detection. That's why I am not inclined to use motion service for streaming.

The fact is that motion-UI is more suitable for use with remote IP cameras that broadcast an MJPEG video stream.

Perhaps I may be missing something, and I might find a simpler solution in the future, but for now, I recommend using ustreamer to turn your local camera into a kind of remote camera.

I'll let you know if I find a better solution in the future ;)

from motion-ui.

samuk avatar samuk commented on June 28, 2024

No problem, makes sense. I'll give ustreamer a go.

from motion-ui.

samuk avatar samuk commented on June 28, 2024

After running through your steps my ustreamer container doesn't have an IP/Port so I'm unsure what to put into the Motion-UI WebUI? ustreamer

from motion-ui.

lbr38 avatar lbr38 commented on June 28, 2024

Have you been able to create a docker network and put both containers in this network?

Because if the ustreamer container is in the same docker network as the motionui container then the motionui container should be able to reach ustreamer without need to know its IP but using its container name (ustreamer). It's just like an hostname.

ustreamer is streaming through the 8080 port, so motionui should reach the stream at http://ustreamer:8080/stream just like in my capture.

from motion-ui.

Related Issues (3)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.