Are there any ways to stream video via Redis for (near) real-time streaming?
Asked Answered
L

1

7

We have a Redis server that all clients attach to for a variety of data transfer and coordination tasks. We have a new requirement that we support video streaming. I would like to avoid running a dedicated service (with all the accompanying network and security requirements that entails) and just stream over Redis.

Redis seems like a good fit for real time streaming, in particular using Redis streams. I realize that "Redis streams" have no relation to "video streaming", however, our use case follows Redis stream structure well. We want to buffer X seconds of video continuously allowing clients to attach to that real-time stream at any time. We have no need to store history or serve static video content.

  • Redis seems like a good solution, my problem is I don't know how to stream an appropriate video codec (Motion JPEG maybe?) over Redis.
  • I wouldn't know how to join a stream mid-broadcast (join at a keyframe perhaps?).
  • I wouldn't know how to serialize the stream to bytes at the server (Python based) and de-serialize the stream to a video codec and player on the client (a browser). Perhaps it's as simple as seralization/deseralization in opencv or equivalent and I'm just over thinking it?

These are all features I would typically look to an API to perform, but is there an API capable of this? I'm inexperienced in the field of video streaming.

Leafstalk answered 6/4, 2022 at 19:31 Comment(1)
You can take a look at Video Transport Stream (TS) file format.Heliotherapy
R
0

At a high level, I prefer viewing streaming as a pub-sub problem. Where producers produce chunks of information and consumers read that information on need basis.

Some solution may not be readily available, we may need to perform the following steps:

Publish:
1. chunk-id : content
2. chunk-id-fwd : (nextChunkId)
3. videoId : latestChunkId (Assuming your realtime usecase is for live streams, this can help users access 'go-live' button)
Consume:
Start:
1. Get latest chunk
2. Get content from latest chunkId
3. Get nextChunkId from chunk-id-fwd
Retrograde answered 18/10, 2022 at 12:20 Comment(1)
I appreciate the thought, but I'm really looking for information on what protocols exist that I might use to implement this over Redis's publish-subscribe framework and what approach can be used to decode that protocol on a client that can connect to Redis as the transport layer. This answer just states that this is a publish-subscribe problem, the pseudo-example only shows a basic binary protocol example. This is effectively an elaboration of the 2nd paragraph of the question, it doesn't address any of the three bullet points in the question.Leafstalk

© 2022 - 2024 — McMap. All rights reserved.