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.
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.
I program it in C++ language.
Thank you very much.
Update 1 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
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
};
My code is
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);
How could i solve it? Thank you very much!
JPEG image is broken into parts according to RFC 2435 "RTP Payload Format for JPEG-compressed Video". You need to merge parts back into valid JPEG following this C# library/method: Saving JPEG file coming from Network Camera RTP Stream