Discussion:
[Live-devel] Questions about media server - MKV, rtsp with multiple video media types
office luksoft.it
2018-10-25 07:18:54 UTC
Permalink
Hi there,


I am recently playing a lot with live555 streaming server, as I need to create a block of larger test environment, responsible for streaming content from some storage. I ran into some questions and it seems I need know-how/knowledge based assistance with regards to live555.



Background scenario:

- stream a video from video file (H264 elementary stream or wrapped in a container) ok

- stream a part of video file starting from specific position (FROM: timestamp)

- stream a video file from specific postion (FROM: timestamp) while it's still being written by some other process

- stream a specified part of video file, start-end (FROM - TO /timestamp)

- stream several video files to one client on demand at the same time - preferrably synchronized (assuming streams fps etc. matches)


I have some questions regarding streaming and one of container formats.

I've chosen to stream video files using RTSP (some player clients handle it ok + live555 rtsp client is in the package) and it seems everything works ok in majority of scenarios.

However, I've run into questions for which neither source code of live555 or available net resources provided answers. Please mind I could miss something in source code, as it's been a while since I was doing C/C++ - so if I ask about something already there, don't get too upset :-)



STREAMING

In case of 'stream several video files to one client', I can handle it with several independent RTSP sessions, however it struck me, that one RTSP session by design can handle multiple media types within one session. I understand intended usage (e.g. vide + audio + subtitles).

QUESTION 1: Could I create RTSP stream with multiple videos in it (assuming something on the client end will understand it) and stream each video properly within that session using LIVE555 Media Server?

QUESTION 2: Do you know any player which could handle such session out of the box (play multiple video streams - multiple windows, or one window, whatever)?

QUESTION 3: In such scenario, an 'aggregate play' option: would it cause all videos start/pause/stop streaming together in live555 media server?

QUESTION 4: 'Aggregate play': would 'play' cause all X videos to be somehow synchronized when FROM: timestamp is provided, e.g. based on IDRs in files?



CONTAINER FORMAT

I was trying to employ MKV container for written files (seeking is a feature I could use a lot), however I've run into issues when trying to stream MKV in FROM - TO (timestamps) manner

It seems the "TO" part is not implemented in live555 server - I can only appoint FROM when in file MKV can be played and by analysing code, it's the only part handled.

And yes, for sake of simplicity it's enough for me to find the first IDR before FROM: timestamp and stop on first IDR after TO: timestamp (and let player handle stuff on client side). If this is 'dumb' approach, I would welcome any piece of advice. I strongly prefer server-side solution for some level of synchronization though (if only possible), as it would do a lot of things on client side much easier.


QUESTION 5: Why 'TO: timestamp' is not handled for MKV playback & streaming? Or if I am mistaken, how to stream MKV file up to appointed 'end' timestamp?


Second issue is connected to 'stream a file while it's being still written' & MKV. I just can't get to understand how to do it (except general guideline on MKV site: https://matroska.org/technical/streaming/index.html , live streaming part). Writing such file part is still an issue for me (I did some experiments with ffmpeg to capture h264 elementary stream and turn it to MKV in stream-manner, but I've failed so far; all I could get is to write it in appointed chunks and only then stream it using live555, when MKV file is complete; so at the end I have series of multiple files; wrapping up a file each e.g. 5-10 seconds is not an option here).


QUESTION 6: Can LIVE555 Media Server stream such 'unfinished' MKV file, which is still being written to? If yes, what are the conditions/how the file must be written to enable that?

QUESTION 7: Could you advise maybe how to create such 'unfinished' MKV file using e.g. ffmpeg or other tool (maybe something from live555 suite can do that)?



Forgive me any grammar/spelling errors - English is not my native language. If something is not clear, please let me know, I'll try to explain more in details (as much as I am allowed or capable of).


Best Regards, Lukas
Ross Finlayson
2018-10-25 08:22:10 UTC
Permalink
I don’t have time to answer all of these questions at once; I suggest asking only one question at a time.

However, you should note that the “LIVE555 Media Server” was intended to be a stand-alone ‘appliance’ application that performs just one particular function (streaming from named files - one at a time), and was not intended to be modified.

For the more complex kinds of streaming that you’re interested in, you should instead use the “testOnDemandRTSPServer” application (in the “testProgs” directory) as a model.

Note in particular that you can "stream several video files to one client on demand at the same time” (though I’m not sure why you’d want to do this) by calling “ServerMediaSession::addSubsession()” several times (once for each video file source) on the same “ServerMediaSession” object.

Finally, you asked why the server currently does not implement the ‘end’ of a RTSP range, when streaming from a Matroska file. The reason for this is that implementing this feature is complicated (because it depends on the particular file time that you’re streaming from), and it would be difficult to implement for a complex file type like Matroska. (We currently implement this only for WAV audio files, because for such files it’s easy to figure out how many bytes of the file to stream before we’re done.)

However, you should note that there’s nothing to stop the RTSP *client* from handling the end of a RTSP range itself - e.g., by sending a “PAUSE” command (or a “TEARDOWN” command, or another “PLAY” command) once it reaches the end of its desired duration.


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
Ross Finlayson
2018-10-25 08:25:30 UTC
Permalink
Post by Ross Finlayson
Finally, you asked why the server currently does not implement the ‘end’ of a RTSP range, when streaming from a Matroska file. The reason for this is that implementing this feature is complicated (because it depends on the particular file time that you’re streaming from)
Oops, I meant to say:
it depends on the particular file *type* that you’re streaming from


Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
office luksoft.it
2018-10-25 09:57:23 UTC
Permalink
Hi Ross

Many thanks for fast response and for your time. The reason for joining questions was to give a context.

“testOnDemandRTSPServer” - noted, will look through it now.

Media Server:

“ServerMediaSession::addSubsession()” - thanks for the hint, yes, that's what I figured.
Post by Ross Finlayson
Note in particular that you can "stream several video files to one client on demand at the same time” (though I’m not sure why you’d want to do this)
Imagine recordings from several cameras, that ought to be displayed on one screen, side by side, time-synchronized. Assume that time is pretty much synchronized during recording, so it's not a big issue. Case to solve: serve somehow synchronized video from server (or at least start serving in sync, rest depends on client player) or develop sync logic on client/client player side. Starting serving in sync much preferred (makes things easier later).

Do you happen to know if any player could handle such RTSP session (with multiple video media types inside) or is it usually done otherwise? Checking possible solutions here.

And while still at Media Server: would aggregate play, when using ServerMediaSession::addSubsession() for each video file, cause Media Server to synchronize mutliple videos start?

Matroska - got it. Thanks for suggestion with RTSP client. Still, can Media Server play a MKV file, which is still being written to by some other process?

Best Regards, Lukas
Post by Ross Finlayson
Post by Ross Finlayson
Finally, you asked why the server currently does not implement the ‘end’ of a RTSP range, when streaming from a Matroska file. The reason for this is that implementing this feature is complicated (because it depends on the particular file time that you’re streaming from)
it depends on the particular file *type* that you’re streaming from
Ross Finlayson
Live Networks, Inc.
http://www.live555.com/
_______________________________________________
live-devel mailing list
http://lists.live555.com/mailman/listinfo/live-devel
Loading...