Re-stream an incoming video stream to another server

159 views
Skip to first unread message

Sol

unread,
Dec 22, 2021, 3:55:15 AM12/22/21
to meetecho-janus
Hi, I've been using Janus Gateway for some months now.

I'm using Streaming plugin to receive rtp video streams from raspberry pi, but I want to do some more stuff (which I couldn't pull off), such as:

Janus server receives a video stream at port 8001 and redirects(re-streams, sends, however we wanna call it) it to my AI server, and the AI server sends back a video stream to Janus server at port 9001, all the process in real time.

I thought of at least 2 ways to do that, but I couldn't figure out how:
  1. Janus server sends the incoming stream(since it is a decrypted, plain data at the server side) directly to the AI server, in real time.
    • Is there a way to do that?

  2. Janus server saves the video stream into local file chunks and sends those chunks to the AI server in real time.
    • I'm aware that there is a recording function built into Janus, but I don't know how I can use that in Streaming plugin.

Any help would be very much appreciated.

Lorenzo Miniero

unread,
Dec 22, 2021, 4:29:29 AM12/22/21
to meetecho-janus
The Streaming plugin doesn't have any RTP forward functionality built in, at the moment, so 1. is not possible. You can record to .mjr in the plugin (see the "recording" request in the plugin documentation), but that won't give you chunks, unless you start/stop recordings often and post-process the smaller files on a regular basis.

It might be easier not to send media directly to port 8001, but send it to another process instead, that then sends it both to 8001 (Streaming plugin) and your AI server. That's how I'd do it at least.

L.

Sol

unread,
Dec 24, 2021, 12:25:35 AM12/24/21
to meetecho-janus
Thank you very much for your reply! It helped a TON with how I'm going to approach it.

I decided to multi-stream to both servers using gstreamer, one to my Janus server port 8001 and another to my AI server, then the AI server will send the processed video to port 9001.

For anyone who might want to know how I did that: 
I used multiudpsink pipeline on gstreamer, like: 
gst-launch-1.0 -v v4l2src device=/dev/video0 ! videoconvert ! videoscale ! videorate ! video/x-raw,width=1280,height=720,framerate=30/1,format=I420 ! omxh264enc target-bitrate=2000000 control-rate=1 ! rtph264pay config-interval=1 pt=96 max-ptime=-1 mtu=1024 ! queue ! multiudpsink clients=ip:port,ip:port

Hope you have a happy holiday/christmas!
Thanks.

2021년 12월 22일 수요일 오후 6시 29분 29초 UTC+9에 lmin...@gmail.com님이 작성:

Sol

unread,
Dec 30, 2021, 12:41:26 AM12/30/21
to meetecho-janus
Okay, I changed my method because it was (obviously) not efficient in terms of network usage.

Janus server receives the stream from another UDP port 10001, and redirects the stream to my AI server and to Janus server's streaming port 8001, 
using the following gstreamer command:

gst-launch-1.0 -v udpsrc port=10001 caps=application/x-rtp,media=video,clock-rate=90000,encoding-name=H264,payload=96 ! rtph264depay ! rtph264pay config-interval=0 pt=96 max-ptime=-1 ! queue ! multiudpsink clients=AI_server_ip:port,127.0.0.1:8001

Then the AI server will send back the AI video to Janus server's port 9001.
It solves my problem.

The structure looks like this:
raspberry pi -> janus port 10001 -> janus port 8001 -> user
                                                          \_> AI server -> janus port 9001  -> user

Hope it helps someone.

2021년 12월 24일 금요일 오후 2시 25분 35초 UTC+9에 Sol님이 작성:
Reply all
Reply to author
Forward
0 new messages