title: MPEG4 out of Raw RTP Payload
body: <p>Okay I got the following problem:</p>
  
  <ol>
  <li><p>I have an IP Camera which is able to stream MPEG4 data over RTP</p></li>
  <li><p>I am able to connect to this camera via RTSP</p></li>
  <li><p>I can receive the raw RTP data.</p></li>
  </ol>
  
  <p>So what problems do I have now?</p>
  
  <p><strong>1. Extract Data</strong></p>
  
  <p>What is the data I actually want? I know that I have to trunkate the <code>RTP Header</code> - but is there anything else I need to cut from the <code>RTP</code> packets?</p>
  
  <p><strong>2. Packetization Mode</strong></p>
  
  <p>I read that I should expect a field <code>Packetization Mode</code> in my <code>SDP</code>- well it's not there. Does that mean I have to assume some kind of standard packetization mode? </p>
  
  <p><strong>3. Depacketization</strong></p>
  
  <p>If I got it right I need to buffer all incoming frames with the <code>Marker Bit = false</code> until I get a frame with <code>Marker Bit = true</code> to get a complete <code>MPEG4 Frame</code>.  What exactly do I have to understand by <code>MPEG4 Frame</code>? Keyframe + data until next keyframe?</p>
  
  <p><strong>4. Decode</strong></p>
  
  <p>Do I have the decode the data any further then? In other threads I saw that people used another decoder - but what is there left to decode? I mean the camera should send the data already <code>MPEG4</code> coded? </p>
  
  <p><strong>5. Libraries</strong></p>
  
  <p>If I really need to decode the data, are there any open libraries I could use for that? Or maybe there is even a library which has some functions where I can just dump my RTP data and then magic happens and I get my mp4. ( But I assume there will be nothing like that .. )</p>
  
  <p><em>Note:</em> Everything I want to do should be part of my own application, meaning for example, I can't use an external software to parse the data.</p>
  
  <p>Well long story short - I'd really need some kind of step by step explanation for this to do. I know this is a broad question but I don't know any further. I also looked into the <code>RFCs</code>, but I couldnt extract much information out of them.</p>
  
  <p>Also I already looked up these two Questions: </p>
  
  <p><a href="https://stackoverflow.com/questions/7665217/how-to-process-raw-udp-packets-so-that-they-can-be-decoded-by-a-decoder-filter-i">How to process raw UDP packets so that they can be decoded by a decoder filter in a directshow source filter</a> </p>
  
  <p><a href="https://stackoverflow.com/questions/7887922/mpeg4-extract-from-rtp-payload">MPEG4 extract from RTP payload</a></p>
  
  <p>But also the long answer from the first question could not make everything clear to me.</p>
  
  <p><strong>UPDATE:</strong> Well I informed a bit further and now I don't know where to look anymore. It seems that all the packetization stuff etc. is actually not needed for my purpose. I also recorded a stream with <a href="http://www.live555.com/openRTSP/" rel="nofollow noreferrer">openRTSP</a>. When I open those files in a Hex-Editor I see that there are 16 Bytes which I can't identify, followed by the <code>config</code> part of the <code>SDP</code>. Then the frame starts with the usual <code>00 00 01 B6</code>. Also <code>oprenRTSP</code> adds some kind of tail to the <code>MP4</code> - well I actually don't know what I need and whats just some "extra" stuff which isn't mandatory. </p>