Sign inSign up

subc/aler9_rtsp_vod_server

By subc

Updated 4 months ago

Image
0

371

subc/aler9_rtsp_vod_server repository overview

About

Based on the repo, https://github.com/aler9/rtsp-simple-server. A rtsp-simple-server_ is a ready-to-use and zero-dependency server and proxy that allows users to publish, read and proxy live video and audio streams through various protocols:

protocoldescriptionpublishreadproxy
RTSPfastest way to publish and read streams:heavy_check_mark::heavy_check_mark::heavy_check_mark:
RTMPallows to interact with legacy software:heavy_check_mark::heavy_check_mark::heavy_check_mark:
HLSallows to embed streams into a web page:x::heavy_check_mark::heavy_check_mark:

Setup

The setup is based on the configuration files

  • rtsp-simple-server.yml
  • video files in the /video folder
  • and Docker

The video files are not included in the repo due to size, but can be download from the ftp using the URL https://ftp.subcservices.com/list/Other/Sample_Videos.

The sample videos included are:

LocationFilenameType
/videos/Seafloor_1080MP4
/videos/Seafloor_720MP4
/videos/Seafloor_SDMP4
/videos/GreenlandShark_1080MP4
/videos/GreenlandShark_720MP4
/videos/GreenlandShark_SDMP4
/videos/Spiny_Lobster_2012MP4
/videos/Swimming_Crinoid_ROVLine_2014MP4
/videos/DolphinsMP4
/videos/Lava_TubesMP4
/videos/Acid_HorizonsMP4
/videos/UWash_Ocean_2020MP4
/videos/Shark_EggMP4
/videos/Titantic_2021MP4

For help with configuration of the file, check out the link, https://github.com/aler9/rtsp-simple-server/blob/main/README.md#configuration. The main usage for us would be related to video on demand(VOD) is https://github.com/aler9/rtsp-simple-server/blob/main/README.md#on-demand-publishing.

A modified sample for us is:

paths:
  all:
    readUser: subcstreams
    readPass: 9jxnpPIl

  GreenlandShark_1080:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/GreenlandShark_1080.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  GreenlandShark_720:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/GreenlandShark_720.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  GreenlandShark_SD:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/GreenlandShark_SD.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  Spiny_Lobster_2012:
      runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Spiny_Lobster_2012.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
      runOnDemandRestart: yes

  Swimming_Crinoid_ROVLine_2014:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Swimming_Crinoid_ROVLine_2014.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  Dolphins:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Dolphins.mp4 -c copy -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  LavaTubes:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Lava_Tubes_HD.mp4 -c copy -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  AcidHorizons:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Acid_Horizons_HD.mp4 -c copy -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  UWashOcean2020:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/UWash_Ocean_2020_HD.mp4 -c copy -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  SharkEgg:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Shark_Egg.mp4 -c copy -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  Titantic2021:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Titantic_2021_HD.mp4 -c copy -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  Seafloor_1080:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Seafloor_1080.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  Seafloor_720:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Seafloor_720.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

  Seafloor_SD:
    runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Seafloor_SD.mp4 -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
    runOnDemandRestart: yes

What is happening with the code is we have several labels starting with all, which includes the readonly username and password. Next, we have our VOD setup's.

Dolphins:
        runOnDemand: ffmpeg -re -stream_loop -1 -i /videos/Dolphins.mp4 -c copy -preset ultrafast -vcodec libx264 -tune zerolatency -b 1000k -f rtsp rtsp://localhost:$RTSP_PORT/$RTSP_PATH
        runOnDemandRestart: yes

You can modify the ffmpeg command to make it work the best possible for the video source your using. The example shown takes the input of /videos/Dolphins.mp4, encodes it into h264 at a bitrate of 1k.

Streaming at the original bitrate or high bitrates can cause issues. Also, streaming at bitrates that are too low will not work within the IP camera setup's on SubC applications.

Docker

As part of the setup, each time you make a change you need to update the docker image online. The steps below will assist..

  1. Install docker desktop on the PC (https://www.docker.com/products/docker-desktop/)
  2. Open a command prompt to the location of the Git Repo and go to the docker folder
  3. When testing, you want to upload to the dev or development image using the command "docker_build dev". But when everything is working correctly, upload to the live image using the command "docker_build live"

Checkout Docker Hub at https://hub.docker.com/repository/docker/subc/aler9_rtsp_vod_server to see all available versions and any notes.

The command or batch file preforms all the needed commands to compile, upload and allows for testing the docker image locally if you wish. Checkout the contents of the batch file to learn more.

I have found this image can cause increase CPU needs when using it, best to keep the VOD limited to one(1) feed for local testing.

Installation

Once the docker image is updated, you can download them to a Windows or Linux machine using the docker run command. Checkout the steps below.

Linux

  1. sudo docker run --name rtspserver -p 10554:10554/tcp -d subc/aler9_rtsp_vod_server:dev or sudo docker run --name rtspserver -p 10554:10554/tcp -d subc/aler9_rtsp_vod_server:live
  2. Use the command sudo docker psto check if the image is running
  3. Make sure the ports 10554/tcp, 10000/tcp and 10001/tcp are open.

Testing

To test if any of the VOD's are working, open one of the below RTSP feeds in SubC Stream, SubC DVR+O, VLC or any other program able to open a RTSP streaming video feed.

NameFilenameRTSP URLDescription
Ocean Seafloor/videos/Seafloor_1080.mp4rtsp://subcstreams:[email protected]:10554/Seafloor_1080Demo video of the ocean seafloor.
Ocean Seafloor/videos/Seafloor_720.mp4rtsp://subcstreams:[email protected]:10554/Seafloor_720Demo video of the ocean seafloor.
Ocean Seafloor/videos/Seafloor_SD.mp4rtsp://subcstreams:[email protected]:10554/Seafloor_SDDemo video of the ocean seafloor.
Greenland Shark/videos/GreenlandShark_1080.mp4rtsp://subcstreams:[email protected]:10554/GreenlandShark_1080Demo video of a shark off Greenland.
Greenland Shark/videos/GreenlandShark_720.mp4rtsp://subcstreams:[email protected]:10554/GreenlandShark_720Demo video of a shark off Greenland.
Greenland Shark/videos/GreenlandShark_SD.mp4rtsp://subcstreams:[email protected]:10554/GreenlandShark_SDDemo video of a shark off Greenland.
Spiny Lobster/videos/Spiny_Lobster_2012.mp4rtsp://subcstreams:[email protected]:10554/Spiny_Lobster_2012Demo video of a lobster.
Swimming Crinoid ROVLive 2014/videos/Swimming_Crinoid_ROVLine_2014.mp4rtsp://subcstreams:[email protected]:10554/Swimming_Crinoid_ROVLine_2014Demo video ROV line from 2014.
Dolphins/videos/Dolphins.mp4rtsp://subcstreams:[email protected]:10554/DolphinsDemo video with Dolphins.
Lava Tubes/videos/Lava_Tubes.mp4rtsp://subcstreams:[email protected]:10554/LavaTubesDemo video with Lava tubes.
Acid Horizons/videos/Acid_Horizons.mp4rtsp://subcstreams:[email protected]:10554/AcidHorizonsDemo video with Acid Horizons.
UWash Ocean 2020/videos/UWash_Ocean_2020.mp4rtsp://subcstreams:[email protected]:10554/UWashOcean2020Demo video with UWash Ocean from 2020.
Shark Egg/videos/Shark_Egg.mp4rtsp://subcstreams:[email protected]:10554/SharkEggDemo video with Shark egg.
Titantic 2021/videos/Titantic_2021.mp4rtsp://subcstreams:[email protected]:10554/Titantic2021Demo video with Titantic 2021.

Viewing the Log File

Inside of the docker container, the system is generating a log file which can be view from the Linux console. You can view the log by getting console access to the docker container and then using the cat command see the output.

Steps from Linux Console

  1. Type sudo docker exec -it rtspserver /bin/sh
  2. Type cat rtsp-simple-server.log

Manually Stopping and Starting the Docker Container

This project is not setup with docker compose at this time. But you can stop and restart the docker container from the console.

To do so, follow the steps below..

Steps

  1. Type sudo docker stop rtspserver
  2. Type sudo docker rm rtspserver
  3. Type sudo docker run --name rtspserver -p 10554:10554/tcp -d subc/aler9_rtsp_vod_server:dev or sudo docker run --name rtspserver -p 10554:10554/tcp -d subc/aler9_rtsp_vod_server:live to startup the server again.

You can also remove all images that are stopped from the system by using the command sudo docker system prune -a -f.

Change Log

DateVersionDescription
2022-May1.0Init version
2022-Aug-081.1Added new videos at the request of sales. Videos added are Shark_Egg.mp4, Lava_Tubes_HD.mp4, UWash_Ocean_2020_HD.mp4, Acid_Horizons_HD.mp4 and Titantic_2021_HD.mp4.
2022-Aug-221.2New versions of Greenland Shark created. 720p and SD version are now available.
2022-Aug-221.3Ocean seafloor video's added.

Tag summary

Content type

Image

Digest

sha256:4d1c6d289

Size

2.2 GB

Last updated

4 months ago

docker pull subc/aler9_rtsp_vod_server:live