0

I'm using ffmpeg to record RTSP MPEG4 stream from camera

  1. RTSP has been established by calling avformat_open_input function
  2. Frame is received from the camera with av_read_packet(contest, &packet) and it is stored in AVPacket structure.
  3. Now I want to parse this frame to determine which is I frame before it is stored to file. Using avcodec_decode_video func which might help me in this case but because there is a delay decoding so it is not good choise for me. Anyway, I want to use another way

Simply I think packet.data contains a RTP format which includes RTP header + RTP data.

I've looked into some other theads such as: how to process draw data packet and parsing MPEG-4 from rtp packet. Actually they look very close what I need and maybe I did something wrong.Therefore, I still cannot figure out where is 12 bytes for RTP header in packet.data and then what I realy need is I, P or B video object plane info.

Trying to parse the RTP format but it seems packet.data either contains some extra information more than a pure RTP format or doesn't contain RTP header. I'm not sure.

Shotly:

How can I parse the frame to get frame info (I, P or B) in AVPacket
Community
  • 1
  • 1
vominhtien961476
  • 317
  • 4
  • 17

1 Answers1

0

I don't use FFmpeg but according to the doc you can access to the raw data with AVPacket.data

At this point maybe you can just do this:

int nalType = packet->data[0] & 0x1F;
if (naType == 5) // iFrame
HaneTV
  • 916
  • 1
  • 7
  • 24
  • Thanks for your answer. Actually, my problem is that I forgot to check type of data (audio or video frame). I was looking the I frame in audio stream and compare with video MPEG4 format that why's I didn't parse the frame properly. I hope no one get the same problem like me – vominhtien961476 Oct 11 '13 at 04:31