If you need the compression of a JPEG, you cannot simply rename the buffer. You must use a library like jpeglib to compress the raw frame data before writing it to the disk. Summary Checklist for Developers
Use a if you need to "grab" a specific frame from the stream.
These are raw formats. While they look similar to the eye, they handle color data differently at the bit level.
This is the easiest method. Since a BMP is essentially raw pixel data with a header, you can write the buffer directly to a file following standard BMP file formatting.
Depending on your project requirements, you have two main paths for saving a frame: