title: How to convert motion jpeg frames from ip camera(rtp stream) to valid jpg image
body: <p>I have received motion jpeg frames from a ip camera by RTP stream, and I try to convert the frames to valid jpg images. My camera model is Secubest PXN-0512P. It multicast the video of motion jpeg data by RTP stream. Now, I have decode the RTP stream and got each frames in memory, and i try to convert it to valid jpg image.</p>
  
  <p>Do you know so tools to complete this function?  And what are the steps to deal with m-jpeg frame? (such as add jpeg-header, huffman table). I am a new programer in this field.</p>
  
  <p>I program it in C++ language.</p>
  
  <p>Thank you very much.</p>
  
  <p><strong>Update 1</strong>
  I try to directly write the recieved frame data to jpg, when i open it at ubuntu, it show warning "Error interpreting JPEG image file (Not a JPEG file: starts with 0x00 0x00)". Then I add a JFIF header to it, it shows warning"Error interpreting JPEG image file (Unsupported marker type 0xf0". 
  Jpeg_header is </p>
  
  <pre><code>char jpg_header1[] = {
          0xff, 0xd8,                          // SOI
          0xff, 0xe0,                          // APP0
          0x00, 0x10,                          // APP0 Hdr size
          0x4a, 0x46, 0x49, 0x46, 0x00, // ID string
          0x01, 0x01,                          // Version
          0x00,                               // Bits per type
          0x00, 0x00,                         // X density
          0x00, 0x00,                         // Y density
          0x00,                               // X Thumbnail size
          0x00                                // Y Thumbnail size
          };
  </code></pre>
  
  <p>My code is </p>
  
  <p><code>m_FileStream.write(jpg_header1, sizeof(jpg_header1));
  int skip_bytes = 2;
  m_FileStream.write(mem_buffer.pData+skip_bytes, mem_buffer.DataSize-skip_bytes);</code></p>
  
  <p>How could i solve it? Thank you very much!</p>