Reputation: 2544
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.
Upvotes: 11
Views: 18774
Reputation: 1292
get a single frame from raw RGBA data
ffmpeg -y -f rawvideo -pix_fmt rgba -ss 00:01 -r 1 -s 320x240 -i input.raw -frames:v 1 output.png
-y
overwrite output
-r
input framerate (placed before -i
)
-ss
skip to this time
-frames:v
number of frames ot output
Upvotes: 0
Reputation: 134063
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
.
Upvotes: 8