2023-11-13

Iterate over list of YouTube/RTSP streams, add text overlays, and expose as a fixed RTSP endpoint

My goal is a shell script or Python utility that cycles through list (.csv, .yaml, or .json) of YouTube/RSTP source streams in a format similar to the following (.csv) example below:

url,overlay_text,delay_ms
rtsp://admin:12345@192.168.1.210:554/Streaming/Channels/101,THIS IS OVERLAY TEXT,5000
https://www.youtube.com/watch?v=dQw4w9WgXcQ,THIS IS MORE OVERLAY TEXT,5000
.
.
.
rtsp://admin:12345@192.168.1.210:554/Streaming/Channels/101,THIS IS OVERLAY TEXT,5000
https://www.youtube.com/watch?v=dQw4w9WgXcQ,THIS IS MORE OVERLAY TEXT,5000

For each record in the text file, the utility will:

  • Capture the stream from the specified source URL
  • Add the overlay_text for that record to the stream
  • Proxy or otherwise expose it as a fixed/unchanging RTSP endpoint
  • Wait delay_ms for that record
  • Kill that stream, go on to the next one, and repeat...exposing the next stream using the same RTSP endpoint. So, to a consumer of that RTSP stream, it just seems like a stream that switched to a different source.
  • When it reaches the last record in the text file, go back to the beginning

It could be as simple as a Bash shell script that reads the input text file and iterates through it, running a Gstreamer gst-launch-1.0 command w the appropriate pipeline arguments.

I can handle the reading of the text file and the iteration in either Bash or Python. I just need to know the proper way to invoke (and kill) gstreamer to add the text overlay and expose as an RTSP endpoint.



No comments:

Post a Comment