Pelco Developer Network (PDN)

Help with RTSP Live Streaming using SDK

If you're using Pelco SDK, use the streamConfig object to assign the StreamProtocol Property to StreamProtocol.Rtsp.

If you need more specific help, please be more specific in your question.

Thanks!

Hi Chris,

Thanks for the response. I have created a Web API application that have successfully retrieved stream images from a defined camera using the RawFrames Example. Now I am trying to output those stream into a RTSP link - "rtsp://127.0.0.1/live/stream", which external parties can use to view the live stream using VLC player or such.

Can this be done using the Pelco SDK or do I have to use something like FFMPEG to take in the image and output the stream? Is there a simple way to do this ?

Thanks and Best Regards

Glad to hear that you have had success.

The RawFrames sample and usage of Pelco SDK is to deliver video frames to the calling application that are then used however you wish. In this case, you would be responsible for rendering those as a stream however you see fit. FFMPEG is an option, we do have developers using their own renderers as well.

If you don't to manage the stream this way, you can use the Pelco SDK Object Model display object (similar to the ViewVideo sample). This uses our own MPF streaming methods. I will say that moving forward into VX SDK and beyond, delivering a stream and then forcing our partners to render it how they wish is our plan, since partners in the past have not been happy about being shackled to our own rendering in Pelco SDK.

Hi Chris,

I have decided to use 'NReco Video Converter 'which is a C# FFMPEG wrapper for my Web API application using the code shown below. However when I tried to get the stream, I received "A first chance exception of type 'System.AppDomainUnloadedException' occurred in Pelco.SDK.DLL". It will also try to look for imediaframesdelegatenet.h which I am unable to find in the Pelco installation folder.

Just in case, I tried implementing the FFMPEG code in RawFrames example and there was no issue. I am stumped and have no idea how to debug this. May I ask for your help and advice?

The Initialization for FFMPEG ConvertLiveMedia and configure output streaming

            ffmpegTask = converter.ConvertLiveMedia(
                null, // no input stream if data is provided with Write method
                Format.raw_video,
                "video.mp4", //output video as a test, will try 'rtsp://127.0.0.1/live/stream' once its ok
                Format.mp4,
                new ConvertSettings()
                {
                    CustomInputArgs = " -re -pix_fmt bgr24 -video_size 1920x1080 -framerate 15 ",
                    CustomOutputArgs = " -acodec copy -vcodec libx264 -pix_fmt yuv420p ",
                });
 
            ffmpegTask.Start();
        }

Code to add Bitmap frames

        private void writeBitmaptoFFmpeg(Bitmap bitmap)
        {
            Bitmap item = bitmap;
            BitmapData bd = item.LockBits(new System.Drawing.Rectangle(0, 0,
                                                            item.Width,
                                                            item.Height),
                                                ImageLockMode.ReadWrite,
                                                System.Drawing.Imaging.PixelFormat.Format24bppRgb);
            byte[] buf = new byte[bd.Stride * item.Height];
            Marshal.Copy(bd.Scan0, buf, 0, buf.Length);
            ffmpegTask.Write(buf, 0, buf.Length);
            item.UnlockBits(bd);          
        }

Thanks and Best Regards

Ok I thought I had it working for a while as the problem seems to have resolve itself. I was able to output a video with no issues. But after restarting my PC, the problem came back again now.

I'm admittedly a little confused as to what you're trying to accomplish with this, sorry to say.

Pelco cameras for years now have RTSP streams built in that you can obtain to stream from, so you would only need to pull raw frames and then create an RTSP stream using them in those edge cases.

Basically RawFrames means grabbing the frames and presenting them how you wish - which is probably why the sample sounds like it's working with the FFMPEG code there. It almost sounds like you're trying to recreate some sort of RTSP server application by using video frames. If that's the case then perhaps I'm confused as to why, when RTSP streams are readily available from Pelco devices. Again - sorry for my confusion there, I'm hopeful you can clarify.

What kind of Pelco system are you trying to pull the video from - an Endura or VideoXpert VMS?

Hi Chris

I am trying to restream the live streaming received from an Endura device which have to be accessed via a System Manager. I did tried looking for a method to use the RTSP streams from Pelco devices but I read that those are meant for Sarix devices. Thus I figured that I had to recreate a RTSP server application to allow a restream for external parties to access. Of course if I am mistaken and there is actually a method from which allows an Endura device to restream the RTSP stream to external parties, I would be glad for it and ask for the way to do so.

Thanks for you help and Best Regards

Sarix cameras that provide RTSP also include Spectra HD models, Sarix Professional models, Esprit HD, Spectra Enhanced and Spectra Professional models, NET54xx and NET55xx encoders, and Optera models as well.

The only Pelco cameras that do not have an RTSP stream available out of the box are older analog models like Spectra IV, Spectra Mini, and older Pelco IP cameras like IP3701 (that's the only one I can remember). It's for this reason that no updates or support for RTSP exist any more because so few cameras actually need it these days. It should only be these edge or old cases that you'd need to re-stream a live stream to provide RTSP.

The topic says it's for Live streams... if it was for Playback from a recorder then I would agree more. RTSP server was installed by default on NSM for playback streaming, but I believe that was also discontinued too (I could be wrong, that might be a question for our product support team).

Here are a few articles about the RTSP streams available on Pelco devices from the Pelco.com Knowledge Base:

https://buildingskb.schneider-electric.com/pelco/view.php?AID=12001

https://buildingskb.schneider-electric.com/pelco/view.php?AID=8901

Another subject of clarification that might help is regarding the system. 'Endura' is the name of the VMS... the System Manager does not provide any streaming. It does act as a controller for the system and keeping track of the devices, a co-ordination and database device all in one. The cameras stream live directly to clients, and playback is streamed from the recorder / NSM.

I hesitate to use terms like "Endura camera" because the camera isn't VMS specific - the same Pelco cameras could be used on an Endura, DigitalSentry, or VideoXpert VMS.

Hi Chris,

Thank you for the clarification, it certainly help clear some of the misunderstanding I have about the streaming. I have tried getting a stream using VLC player based on this url - rtsp://192.168.5.248/stream1m and I am always receiving these errors :

live555 error: Failed to connect with rtsp://192.168.5.248/stream1m
core error: open of `rtsp://192.168.5.248/stream1m' failed

Am I missing something? Do I need to install live555?

Thanks again Chris for your help and patience.

Best Regards

Try unicast: ".../stream1". If you're connecting to our lab VPN, as an example, multicast will not work.

If you're connecting to our Partner lab, that is a simulated virtual camera. If I use unicast, I'm able to stream from 192.168.5.248. Admittedly I would recommend some of the other devices that are 'actual' cameras in our lab rather then the simulated one, but it did work using VLC for me just a few moments ago. The trick is that you must use unicast.

If you aren't using the lab, I'd recommend using Wireshark to see what the RTSP requests look like on the network to try and identify where the root of the problem is (this trick won't work over VPN if you are using the lab).

Hi Chris,

For clarification, I am connecting to Pelco VPN to use the cameras available. As suggested, I have tried to use Unicast for streaming RTSP using VLC but somehow every attempt failed. Am I missing something? Are my IP address correct? The following are the cameras that I have tried :

Name : IP Camera - IX10DNAAPHED5 IP : 192.168.5.243:80
Name: IP Camera - PC_VIRT-PC 15 FPS-1 IP : 192.168.5.248:80
Name: IP Camera - P1220-T6 1105411 IP : 192.168.5.230:80
Name: NET5504-K4 1600043 Camera 04 IP : 192.168.5.221:80
Name: IMM12018-BASE-G250003 - 1 IP : 192.168.5.72:80

Thanks and Best Regards

Thanks for the clarification. Unfortunately this may not be something that we can resolve; streaming from the lab can be inconsistent depending on how far the stream is trying to go to reach you. I've tested again this morning and I'm able to stream from every single one of those sources while connected to the VPN, so it may be a WAN issue. These are the URLs that I used for the sources you listed:

IX10DN: rtsp://192.168.5.243/stream1
PC_VIRT-PC (may be hit and miss since this is a simulated camera): rtsp://192.168.5.248/stream1
Spectra Pro P1220: rtsp://192.168.5.230/stream1
NET5504: rtsp://192.168.5.221/channel1/stream1

this URL format is slightly different because it's a NET55xx encoder, see my previous Knowledge Base article links on that one Article #12001

Optera IMM12018:rtsp://192.168.5.72/stream1

Optera's RTSP URLs are slightly different, as detailed on this PDN page for working with the Optera Toolkit: Immersive Toolkit FAQA StreamDiscovery::StreamQuery request to camera_ip/control/StreamDiscovery-X will return the 3 RTSP URLS:
Channel 1 (often the default) returns rtsp://camera_ip/mosaic_v or rtsp://camera_ip/mosaicm_v for multicast.
Channel 2 returns rtsp://camera_ip/right_v or rtsp://camera_ip/rightm_v for multicast.
Channel 3 returns rtsp://camera_ip/front_v or rtsp://camera_ip/frontm_v for multicast.
- See more at: http://pdn.pelco.com/content/immersive-toolkit-frequently-asked-questions#sthash.bUcNGnWM.dpuf

All of these streams are working to stream for me while on site and connected to the lab over VPN - they are online. Unfortunately, I believe that if every camera in the lab isn't working for you over the VPN then it's probably a problem with the wide area network connection over to the lab that we may not be able to resolve. You might try lower resolution cameras or setting a physical camera (not a virtual one) to lower resolution and/or trying to stream secondary stream perhaps.

If none of these cameras stream for you at all no matter what you try, then using the lab for these tests may not be a testing solution that will work for you, unfortunately.

Well I guess I'm going to have to keep using the Pelco SDK RawFrames method for streaming for now. But this has certainly taught me much on Pelco RTSP streaming and I will try it again once my system manager and cameras have been set up. Thanks for all your help Chris, I would have been lost and mostly guessing my way through this whole thing without your help.

Thank you very much and Best Regards

You are very welcome!