سؤال

how do i take Data from a FIBITMAP (Free-Image image) object and store it into a binary file.

i already know how to store the data as an image but i would like to instead store it as a video akin to Fraps. my goal is to create a list of FIBITMAP images and write to them in a binary (.avi or .mp4 format) file.

this is my ScreenShot Code:

   BYTE* pixels = new BYTE[ 3 * width * height];    

glReadPixels(0, 0, width, height, GL_BGR, GL_UNSIGNED_BYTE, pixels);

// Convert to FreeImage format & save to file
FIBITMAP* image = FreeImage_ConvertFromRawBits(pixels, width, height, 3 * width, 24,             0x0000FF, 0xFF0000, 0x00FF00);
FreeImage_Save(FIF_PNG, image, "./images/test.avi");

// Free resources
FreeImage_Unload(image);
delete[] pixels;
هل كانت مفيدة؟

المحلول

Let's say you want to save it in avi. That is a container format, which specifies the stored video stream's meta-data (resolution of the frames, codec information, etc) and the stream itself. There are many places where you can study the format of it, and also RIFF in general.

The other thing is that if you want to play your video file with an "outsider" software, then you have to provide a codec for the system, what the player software will find through your OS (you register the codec somehow, that's OS dependent), and the codec will decode the video stream contained in the avi and supply the frames to the player. (Actually the player calls the decode function with chunks of the stream, and your codec should co-operate).

Of course in your video stream each frame is independent and independently coded from the others. But that doesn't matter from the OS-codec point of view. Your codec has an identifier (FOURCC), which should be set into the AVI codec section, and the player will search the codec using that identifier.

Maybe in your place I may think of motion JPEG. That's the closest existing thing compared to what you do. Only in that case the individual frames are not pngs but jpegs.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top