1

I am implementing RTSP in C# using an Axis IP Camera. Everything is working fine but when i try to display the video, I am getting first few frames with lots of Green Patches. I suspect the issue that I am not sending the i-frame first to the client.

Hence, I want to know the algorithm required to detect an i-frame in RTP Packet.

Cœur
  • 37,241
  • 25
  • 195
  • 267
Marshal
  • 33
  • 2
  • 4

2 Answers2

1

when initiating a RTSP-Session the server normaly starts the RTP-stream with config-data followed by the first I-Frame.

It is thinkable, that your Axis-camera is set to "always multicast" - in this case the RTSP-communication leads to a SDP description which tells the client all necessary network and streaming details for receiving the multicast stream.

Since the multicast stream is always present, you most probably receive some P- or B- frames first (depending on GOP-size).

You can detect these P/B-frames in your RTP client the same way you were detecting the I-frames as suggested by Ralf by identyfieng them via the NAL-unit type. Simply skip all frames in the RTP client until you receive the first I-frame. Now you can forward all following frames to the decoder.

or you gave to change you camera settings!

jens.

ps: don't forget that you have fragmentation in your RTP stream - that means that beside of the RTP header there are some fragmentation information. Before identifying a frame you have to reassemble it.

jenseb
  • 1,593
  • 1
  • 10
  • 13
0

It depends on the video media type. If you take H.264 for instance, you would look at the NAL unit header to check the nal unit type.

The green patches can indeed be caused by not having received an iframe first.

Ralf
  • 9,405
  • 2
  • 28
  • 46
  • Hi Ralf , Thanks for the reply.... I am using MPEG4 stream. Now i have managed to get the algorithm for detecting i-frame but as you are saying "The green patches can indeed be caused by not having received an iframe first.", how do i ensure that i always receive the i-frame first?? – Marshal Mar 09 '11 at 01:33
  • The easiest thing to do like jenseb mentioned is too simply drop all frames until you detect the first i-frame. I'm not familiar with the axis camera, but perhaps you can configure the i-frame frequency to make sure that you don't have to wait too long. – Ralf Mar 09 '11 at 13:29