How to add a USB Webcam to Shinobi
Adding a USB Webcam is similar to Adding an MJPEG Camera. You need to manually tune a lot of the configuration to get it working just right. Learn how to do that here.
Before Continuing
USB Webcams should rarely be used because they normally require that the host machine do the encoding for the video data into necessary formats, like H.264-type data. If your camera is capable of providing an H.264 Stream then it's possible for you to only follow the Connection section in this article and resume setup with settings found in the articles linked below.
Using H.264 data will lower a large amount of resource usage on your Shinobi server. Assuming you choose to use optimized settings.
- How I Optimized my RTSP Camera
- View H.264 and H.265 streams in the browser with Shinobi and maintain low CPU use
Minor Internal Optimization
It is rare that a USB webcam allows configuration but if it does you may consider these settings below. Assume your USB camera cannot change these settings internally unless you have a reason to believe otherwise.
- Framerate (FPS) : High : 10 - 15 FPS, Low : 2-5 FPS
- Bit Rate : between 256kbps and 1Mpbs
- Bit Rate Type : VBR (low bandwidth) or CBR (use if frequent image distortion occurs on VBR)
Settings in Shinobi
The connection path for a USB Webcam may vary from system to system. On Linux it is common to find connected cameras at a /dev/videoX path. The X at the end is meant to be replaced with a number starting from 0. See an example of connecting to the first camera (/dev/video0) below.
To find other cameras on Linux you may search for more /dev/videoX paths.
For the Connection section I used:
- Input Type : Local
- Full URL Path : /dev/video0 (Example)
For the Input section I used:
- Analyzation Duration : 1000000
- Probe Size : 1000000
- Monitor Capture Rate : Should match the stream. Probe the stream if you need to find it.
For the Stream section I used:
- Stream Type : MJPEG or Base64 over Websocket
- FPS (Frame Rate) : Should match the stream.
You may consider using another Stream Type like HLS or Poseidon but you will need to make sure of the following settings if doing so.
- Stream Type : HLS or Poseidon
- Video Codec : libx264
- Audio Codec : aac or No Audio
For the Record section I used:
- Video Codec : libx264
- Audio Codec : aac or No Audio
- FPS (Frame Rate) : Should match the stream.
For Global Detector Settings section I used:
- Send Frames : Yes
- Save Events to SQL : Yes (if you want to view the dots in Power Video Viewer)
- Feed-in Image Width : 640
- Feed-in Image Height : 480
- How to Record : Traditional Recording
- Trigger Record : Yes
- Recording Timeout : 2
For Motion Detection section I used:
- Use Built-In : yes
- Indifference : Varies based on camera view point
- Full Frame Detection or Regions
For Traditional Recording section I used in combination with Global Detector Settings:
- Video Codec : libx264
- Audio Codec : No Audio (MJPEG does not carry Audio)
- Segment Length : 2 (creates 5 second buffer)
- HLS List Size : 3 to 10