Context
I used a C++
program to write raw bytes to a file (image.raw) in RGB32
format:
R G B A R G B A R G B A ...
and I want to be able to view it in some way. I have the dimensions of the image.
My tools are limited to command line commands (e.g. ffmpeg
). I have visited the ffmpeg
website for instructions, but it deals more with converting videos to images.
Questions
Is it possible to turn this file into a viewable file type (e.g. .jpeg
, .png
) using ffmpeg
. If so, how would I do it?
If it's not possible, is there a way I can use another command?
It that's still not viable, is there any way I can manipulate the RGB32
bytes inside a C++ program to make it more suitable without the use of external libraries? I also don't want to encode .jpeg
myself like this.
FFmpeg is an outstanding command line tool that helps you do plenty of things with images and videos. By using ffmpeg, you can convert an image sequence into a video file.
To convert a RAW file to a JPEG image file, open your RAW file in your chosen editing software. From there, simply make a copy of the file, save, and export it as a new JPEG image file. You'll then have two files — the original RAW file and the converted JPEG image.
Use the rawvideo demuxer:
ffmpeg -f rawvideo -pixel_format rgba -video_size 320x240 -i input.raw output.png
Since there is no header specifying the assumed video parameters you must specify them, as shown above, in order to be able to decode the data correctly.
See ffmpeg -pix_fmts
for a list of supported input pixel formats which may help you choose the appropriate -pixel_format
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With