Convert RGB32 source file to JPEG or PNG using FFmpeg

Context

I used the program C++to write raw bytes to a file (image.raw) in the format RGB32:

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

My tools are limited to command line commands (e.g. ffmpeg). I visited ffmpeg the website for instructions, but it is more suitable for converting videos to images.


Questions

Is it possible to include this file in the file type of the visible (for example .jpeg, .png) using ffmpeg. If so, how do I do this?

If this is not possible, can another command be used?

This is still not viable, is there a way to manipulate bytes RGB32inside a C ++ program to make it more convenient without using external libraries? I also do not want to code .jpegmyself like this .

+6
source share
1 answer

Use rawwideo demuxer :

ffmpeg -f rawvideo -pixel_format rgba -video_size 320x240 -i input.raw output.png

Since there is no header defining the intended video parameters, you must specify them as shown above in order to be able to decode the data correctly.

See ffmpeg -pix_fmtsfor a list of supported input pixel formats that can help you choose the right one -pixel_format.

+2

All Articles