Skip to content

Instantly share code, notes, and snippets.

@ejdoh1
Last active May 4, 2021 04:58
Show Gist options
  • Save ejdoh1/72d2bcaa40700041ac8411dabdd0309a to your computer and use it in GitHub Desktop.
Save ejdoh1/72d2bcaa40700041ac8411dabdd0309a to your computer and use it in GitHub Desktop.
RTSP Forwarding

Overview

This is information for how to forward a video stream from an RTSP server to another RTSP server with an Android smartphone. For demo purposes it uses the MacOS webcam to create a RTSP stream which is forwarded to a cloud hosted RTSP server

Prerequisites

  • Macbook with webcam, ffmpeg and ffplay installed.
  • Docker.
  • Android phone with app FFmpegui installed & configure to use the built-in binary.
  • Cloud docker container hosting (Azure ACI, AWS ECS, etc)

Steps

Step 1

Create a cloud hosted docker container for the image aler9/rtsp-simple-server and expose port 8554 TCP to the public.

Note down the public DNS name / IP address.

Step 2

On your macbook, create an RTSP server.

docker run --rm -it -e RTSP_PROTOCOLS=tcp -p 8554:8554 -p 1935:1935 aler9/rtsp-simple-server

Step 3

On your macbook, send your webcam video to the RTSP server

ffmpeg -f avfoundation -framerate 30 -video_size 640x480 -i "0:none" -preset ultrafast -tune zerolatency -f rtsp rtsp://localhost:8554/test

Step 4

On your Android, open FFmpegui and run:

ffmpeg -i rtsp://<MAC_IP_ADDRESS>:8554/test -framerate 30 -video_size 640x480 -preset ultrafast -tune zerolatency -f rtsp rtsp://<CLOUD_RTSP_SERVER_IP>:8554/test

Step 5

Check the stream is getting to the cloud RTSP server by running:

ffplay -fflags nobuffer -flags low_delay -framedrop -strict experimental rtsp://<CLOUD_RTSP_SERVER_IP>:8554/test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment