how to save all frames from a video file as a jpeg image
-
Hi all, I want to save each frame from a video file(.cam).I wrote the following coding to get the image.
CFile cf; CString filename; int xu_flag; BITMAPFILEHEADER xufileheader; char * xu_sp; long outputlen; filename = "c:\\temp\\test.jpg"; xufileheader.bfOffBits = 54; xufileheader.bfSize = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) +sizeof(BITMAPFILEHEADER); xufileheader.bfType = 0x4d42; xu_sp = new char [xu_newwidth * xu_newheight * 3+ sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER)]; outputlen = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); memcpy(xu_sp, &xufileheader, sizeof(BITMAPFILEHEADER)); memcpy(xu_sp + sizeof(BITMAPFILEHEADER), xu_buff, (xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER))); xu_flag = cf.Open(filename, CFile::modeCreate | CFile::modeWrite); cf.WriteHuge(xu_sp, outputlen); cf.Close();
But my problem is,I can able to catch only one frame at a time.But i need to save all the frames. How do i acheive this? help me please sunita ramesh -
Hi all, I want to save each frame from a video file(.cam).I wrote the following coding to get the image.
CFile cf; CString filename; int xu_flag; BITMAPFILEHEADER xufileheader; char * xu_sp; long outputlen; filename = "c:\\temp\\test.jpg"; xufileheader.bfOffBits = 54; xufileheader.bfSize = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) +sizeof(BITMAPFILEHEADER); xufileheader.bfType = 0x4d42; xu_sp = new char [xu_newwidth * xu_newheight * 3+ sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER)]; outputlen = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); memcpy(xu_sp, &xufileheader, sizeof(BITMAPFILEHEADER)); memcpy(xu_sp + sizeof(BITMAPFILEHEADER), xu_buff, (xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER))); xu_flag = cf.Open(filename, CFile::modeCreate | CFile::modeWrite); cf.WriteHuge(xu_sp, outputlen); cf.Close();
But my problem is,I can able to catch only one frame at a time.But i need to save all the frames. How do i acheive this? help me please sunita ramesh -
Hi all, I want to save each frame from a video file(.cam).I wrote the following coding to get the image.
CFile cf; CString filename; int xu_flag; BITMAPFILEHEADER xufileheader; char * xu_sp; long outputlen; filename = "c:\\temp\\test.jpg"; xufileheader.bfOffBits = 54; xufileheader.bfSize = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) +sizeof(BITMAPFILEHEADER); xufileheader.bfType = 0x4d42; xu_sp = new char [xu_newwidth * xu_newheight * 3+ sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER)]; outputlen = xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER) + sizeof(BITMAPFILEHEADER); memcpy(xu_sp, &xufileheader, sizeof(BITMAPFILEHEADER)); memcpy(xu_sp + sizeof(BITMAPFILEHEADER), xu_buff, (xu_newwidth * xu_newheight * 3 + sizeof(BITMAPINFOHEADER))); xu_flag = cf.Open(filename, CFile::modeCreate | CFile::modeWrite); cf.WriteHuge(xu_sp, outputlen); cf.Close();
But my problem is,I can able to catch only one frame at a time.But i need to save all the frames. How do i acheive this? help me please sunita rameshMaybe I'm missing something here, but jpg files aren't made to store movies. The jpg file format is only able to store one frame of image data. You need to use another format, AVI, WMF, Quicktime, Realvideo, Tiff...if you want to store multiple frames. On the other hand, if you save each frame to a separate jpg file then it will work, but then you'll have to deal with all those jpg's and find or make a player that can play them back in sequence.