3

I am trying to decode H264 video frames received through RTSP streaming.

I followed this post: How to process raw UDP packets so that they can be decoded by a decoder filter in a directshow source filter

I was able to identify start of the frame & end of the frame in RTP packets and reconstructed my Video Frame.

But I didnt receive any SPS,PPS data from my RTSP session. I looked for string "sprop-parameter-sets" in my SDP(Session Description Protocol) and there was none.

Reconstructing Video Frame from RTP Packets:

Payload in the first RTP Packet goes like this : "1c 80 00 00 01 61 9a 03 03 6a 59 ff 97 e0 a9 f6"

This says that its a fragmented data("1C") and start of the frame("80"). I copied the rest of the payload data(except the first 2 bytes "1C 80").

Following RTP Packets have the "Payload" start with "1C 00" which is continuation of the frame data. I kept adding payload data(except the first 2 bytes "1C 00") into the byte buffer for all the following RTP Packets.

When I get the RTP packet with payload starts with "1C 40", which is end of the frame, I copied the rest of the payload data(except the first 2 bytes "1C 40") of that RTP Packet into the byte buffer.

Thus I reconstructed the Video Frame into the byte buffer.

Then I prepended 4 bytes [0x00, 0x00 , 0x00, 0x01] to the byte buffer before sending to the decoder, because I didnt receive any SPS, PPS NAL bytes.

When I send this byte buffer to the decoder, decoder fails when it tries to initialize sws Context.

Am I sending the NAL bytes and video frame data correctly?

Community
  • 1
  • 1
Praveen
  • 31
  • 1
  • Very strange as the decoder should have no concept of the scalar. sws is the software scaler context. Are you trying to decode using the scaler? – szatmary Mar 26 '15 at 20:43
  • It was a long time ago, but as far as I remember, you already got 0x00, 0x00, 0x00, 0x01 in the beginning, just the first byte happens to interfere with FU type. BTW, it's better to parse frame structure using RFC and h264 standard, not SO thread :-) https://tools.ietf.org/html/rfc6184 , http://www.itu.int/rec/T-REC-H.264-201003-S/en – Dmitri Sosnik Mar 27 '15 at 03:46
  • @szatmary : I am using the Ffmpeg libraries in my Java application through JNI. When I get the frame through RTSP, I pass to the JNI layer to decode using the Ffmpeg libraries. I got an error message, when I called sws_getContext. – Praveen Mar 27 '15 at 13:29
  • Did you decode the frame first? sws operates on decoded frames. The sws error is completely unrelated to AVC start codes. Maybe post some code? – szatmary Mar 30 '15 at 20:14

0 Answers0