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.
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
.