Pelco Developer Network (PDN)

SDK Streaming and Stability

Original question from another post moved here to create new topic. Original question can be found here: Problems with video streaming/playback on VideoXpert

Environment: 1 OPS-WKS and 1 SERVER / MG v10 with 2 Pelco IME cams installed on a single switch. Also a high end Workstation running Windows 8.1.

I have adapted the C# sample app to simply cycle between 2 cameras every 2 seconds. Start a stream, stop the stream, and so forth. After some random time (10-30 minutes, sometimes more, sometimes less) the app throws an unknown external exception in the MediControl.CPP around the lines to either _control->GotoLive(); or _control->Stop();
OR the video simply freezes for some time and then quickly flip-flops between the cameras quickly. This occurs on ANY machine I try it on. Increasing the frequency of the timer to add more time between changes slows this process down. Around 5 seconds the issue goes away. I am not doing any bells and whistles, just a couple of lines of code to display a camera. I have also tried several variations in case of some resource issue by reusing the variable I set the mediacontrol to and / or just creating a new instance every time I start to display a camera and then dispose it. Doesn't make any difference. The program is not showing any unusual memory usage while running or when it errors out. Muticast / Unicast settings on Core make no difference
Any ideas? Five seconds is to long.

- See more at: http://pdn.pelco.com/forum-topic/problems-video-streamingplayback-videoxpert#sthash.BwngV1EY.dpuf

Hello there -

This question is a bit of a tricky one. The short version of the answer is that MediaController sample is simply not designed for this scenario.

The MediaController sample is designed to show just a basic implementation of Gstreamer. Part of that design is using gst-launch to create the video pipeline. The approach that is used in this sample requires the pipeline to be torn down and recreated whenever the source is changed. This means that when stop is called, the pipeline is torn down and then recreated when the play call is made. This is specifically why the MediaController sample is not ideal for this scenario.

One potential approach may be to use a Gstreamer plugin such as Input-selector. You could set up multiple stream inputs and then use that plugin in order to switch between them.

Another possible approach might be to update the pipline while it's actively running. Gstreamer has documentation about how this is done which can be found here: Pipeline Manipulation (the "forcing a format" section is probably the closest example). For this scenario specifically we'd probably initialize both RTSP streams - assuming that they are both live video - and keep them running. Then use Gstreamer to alternate between displaying them. Stream A would be sent to Port A and Stream B would be sent to Port B. Set up Gstreamer to play Stream A then change the caps filter and receiving port dynamically in Gstreamer to use the settings for Stream B. Doing this will keep the pipeline active and allow Gstreamer to reconfigure itself dynamically to receive the other stream. Keep repeating the process between the two streams. This would mean that there's a minimal amount of setup that is done during the switches.

It's worth noting that Gstreamer is very powerful and has a lot of functionality beyond what the Vx SDK sample code uses. The implementation in MediaController is not always the right approach for any given situation, but instead is intended to be a simple sample of one potential avenue to obtain a stream simply for demonstration. More complex interactions involves learning to use it in the manner you wish specifically.