Origin -- Edge -- STB over RTMP: keyframe issue?

Hi!

Setup includes Origin server, Edge server, mag250 STB, and live streams over RTMP.

If stream was already started up when STB connects to play it, everything works fine. So for example streams started with StartupStreams.xml, or streams that were already started and are active on Edge server, works good.

But if this is the first time box requests this stream from Edge (triggering stream startup) - there is no video, only sound on the box. If you move away from this channel and get back to it, while Edge server did not stop the streaming yet, picture will appear.

(Same setup works fine on web players and in VLC, so this issue is specific to mag250 STB and maybe some other boxes)

Is there any setting that will allow Edge server to wait for a keyframe before actually starting streaming to STB, or some buffer, or delay between stream launch on Edge and streaming it out, or anything of this sort, that will allow recently started stream to be fully prepared, before streaming it to the client?

First approach did not help, while second defeats the whole purpose of Origin-Edge configuration for us. We have multiple Origin servers, and dozens of Edges, and few hundred live channels, we just cant lock Edges to Origins - we need streams to be pulled from Origin to Edge only by demand.

I can add something to the initial input, or rework it a bit.

Case 1. No picture on STB

Origin: stream is up and running, launched from StartupStreams.xls

Edge: stream configured in .stream file, currently not running

Box connects to Edge

Stream starts on Edge

Box has sound but no picture

Case 2. STB has picture

Origin: stream is up and running, launched from StartupStreams.xls

Edge: stream is up and running, launched by previous box connection (and still is up, timeout did not happen yet, or there are more clients "holding" this stream)

Box connects to Edge

Box has sound and picture

Case 3. STB has picture v2

Origin: stream is up and running, launched from StartupStreams.xls

Edge: stream is up and running, launched by previous box connection (and still is up, timeout did not happen yet)

Box connects to Edge

Box has sound and picture

Now we restart Application on Edge

Box looses feed

Application started, box connects to it

Stream starts on Edge

Box has sound and picture

By comparing cases 2 and 3 we see that if box managed to get proper video once, and it did not have a chance to destroy its player instance or reset it (app restart is fast enough, and we did not change channel on the box since last succesful playback) - it starts playback properly from recently launched on the Edge stream.

In case 3, it looks pretty much like box has some crucial piece of data stuck/buffered after first playback, that helps to resume playback properly. It does not work without it. It looks a lot like a keyframe.

The following code on Edge eliminates the issue (obviously not good for production, just a research), so there is definitely something wrong with a stream in the first few seconds after it is being pulled from Origin

UPD: *Sometimes* eliminates the issue

UPD2: Changing sleep(5000) to sleep(10000) makes it enough to work 10 times from 10

So question now comes down to what is the event we need to wait for, before starting streaming to mag250 client, when stream is just started.

And can it be fixed with some patch so no need in workarounds?

OR, shell we try to change some settings on Origin?

UPD:

In a normal Edge environment, stream pulling from Origin will not be initialized until invokePrevious in Play()

So waiting for an event is not an option, unless we manually start stream in Play(), and stop/destroy it when there are no clients for it left. It is basically re-doing what Edge is supposed to do, but with this delay added between stream start and streaming to client.

It sounds like the STB is possiby timing out its video playback as it has not received any video frames within a certain time after receiving audio, so it thinks it is an audio only stream. It will vary the amount of time to set up from the edge to the origin and it may also be a factor with the STB that it needs a keyframe quite soon after the connection (hard to say).

The only real solution to this would be to have a barker style channel solution - so

- Using the stream publisher api publish a file to an output stream - Hook 1

- The STB can always connect to the output stream and it could show your logo or similar

- When a connection is made to the output stream, this triggers the mediacaster API to get the stream from the origin

- Using Hook1 switch the content from the barker content to the mediacaster stream to the output

- Any new connections would just see the output channel as from the origin

- When no one is watching the output drop back to the barker content and stop the mediacaster connection