Project

General

Profile

Actions

Alternative Idea #990

open

Streaming RTSP cameras as webcams

Added by Hammel 11 months ago. Updated 10 months ago.

Status:
New
Priority:
Urgent
Assignee:
Target version:
Start date:
22 May 2023
Due date:
% Done:

0%

Estimated time:
Severity:
03 - Medium

Description

In order to provide support for RTSP only cameras (which are higher end but better quality), the following script can be used. It just requires a properly build ffmpeg and the v4l2loopback kernel module to convert the RTSP stream into MJPEG, which could then be streamed via mjpeg-streamer. It creates /dev/video2 and /dev/video3 as separate video devices but there is only one ffmpeg streaming to /dev/video2 (/dev/video3 is not used in this example, but could be to create multiple mjpeg streams for the same camera.

#!/usr/bin/bash
CAMERA_IP="192.168.101.47" 
RESOLUTION="1280x720" 

# List video devices
echo "Video Devices:" 
ls -1 /dev/video*

# Create a virtual webcam
sudo modprobe v4l2loopback devices=2 video_nr=2,3 max_buffers=2 card_label="QSC PTZ" exclusive_caps=1
echo "Video Devices:" 
ls -1 /dev/video*
sleep 2

# Streams a remote RTSP camera to virtual webcam.
ffmpeg -rtsp_transport tcp -protocol_whitelist rtp,file,udp,tcp -stream_loop -1 -re -i rtsp://${CAMERA_IP} -f v4l2 -vf format=yuv420p -vcodec mjpeg -s ${RESOLUTION} -threads 0 /dev/video2

# Remove the V4l2 loopback module
sleep 2
sudo rmmod v4l2loopback

It seems this could be an extension to the current webcam request by adding MA_RTSP to MT_STREAM.

Actions #1

Updated by Hammel 10 months ago

  • Project changed from PiBox to piboxd
  • Description updated (diff)
  • Category deleted (Systems)
Actions

Also available in: Atom PDF