2

I'm trying to extract mpeg4 from an rtp payload , format of the rtsp media (video) is MP4V-ES but I'm not able to extract the mp4 from the payload . when I dump the extract into a raw file and use ffmpeg to convert it into .avi or .mpg its not working. I don't know what I'm missing here. the code is written in java. I want to extract each video frame from the rtp and save that in a file or retransmit it.

Thanks

Question UPDATED..... Thanks for the inputs, actually I'm able to extract bytes from 000001b6 and sent it to ffmpeg , but it complains about not header information and then I constructed a header with 000001b0 00000000 and 000001B5 00000005 and sent that to the ffmpeg but no luck. can you help me here, because what I'm getting from RTP is 000001b6 [data] and again 000001b6 [data] I even followed 'Cipi' to just add 000001 but not working. am I missing something here ! and also want to know whether I need to decode/encode as what I get from the RTP is the actual mpeg4 data right then I don't know why to decode it , can I just save it a file and open with quicktime or VLC and it shoud show one frame right.

darleys
  • 412
  • 4
  • 10

1 Answers1

1

MPEG-4 Video RTP payload is described in RTP Payload Format for MPEG-4 Audio/Visual Streams.

See also How to process raw UDP packets so that they can be decoded by a decoder filter in a directshow source filter with a brief description of steps you need to reconstruct the MPEG-4 video stream.

Update: You might need to look for B0 and B5 in your session descriptor. So that you know where to look for, here is an example of MPEG-4 RTSP/SDP response:

RTSP/1.0 200 OK
CSeq: 2
Content-Base: rtsp://192.168.0.57/webcam/
Content-Type: application/sdp
Content-Length: 320

v=0
o=- 1 1 IN IP4 127.0.0.1
s=Test
a=type:broadcast
t=0 0
c=IN IP4 0.0.0.0
m=video 0 RTP/AVP 96
a=rtpmap:96 MP4V-ES/90000
a=fmtp:96 profile-level-id=1;config=000001B003000001B509000001000000012000C488BA9850584121463F
a=control:track0
m=audio 0 RTP/AVP 97
a=rtpmap:97 AMR/8000/1
a=fmtp:97
a=control:track1
Community
  • 1
  • 1
Roman R.
  • 68,205
  • 6
  • 94
  • 158
  • What do you get in your `RTSP` `SDP`, do you happen to have missing `B0` and `B5` there? – Roman R. Oct 26 '11 at 06:31
  • I got the SDP packet header & added it as a part of the header.but when I just ffmpeg ONE frame to jpg or avi like this it throws [mpeg4 @ 0x2108580]warning: first frame is no keyframe. the file contains just one frame. with headers and frame starting at 000001B6 the file size is around just 1.35KB – darleys Oct 26 '11 at 07:49
  • Roman, realistically I should just add the header 000001B008000001B58913000001000000012000C488BA98514043C1463F (this is what I get from my RTSP config) and add the all the frames starting with 000001B6 and save it as a ".mpg" file right it should just work if I open it in quicktime or VLC right? infact thats what I'm trying but quicktime and vlc throws an error – darleys Oct 27 '11 at 06:22
  • This looks like you are doing it right. The stream itself might be broken? Such as the camera sends first frame broken and then later it catches up and it goes good from there. – Roman R. Oct 27 '11 at 06:29
  • but I'm dumping all the frames each starting 000001B6 into one FILE (.mpg) and one header for all , I'm dumping for 1 minute and then opening the file with one header and multiple frames in quicktim/vlc. – darleys Oct 27 '11 at 06:33