cancel
Showing results for 
Search instead for 
Did you mean: 

How to encode (preferably lossless) video from RGB images using software on STM32F7

ZThat
Senior

I am attempting to encode some images as a video file on the STM32F769NIHx chip. A fairly short, but lossless video file with a very low framerate. I have not found any good resources on how to do so. The framerate will be about 5fps so I don't think that I will need very much compression. It just needs to be accepted by popular/widely available videoplayers as a valid video format.

I have already attempted using FFmpeg, but the documentation online does not provide a way to transfer FFmpeg source code to a bare-metal application. I should say that I am doing all of this in embedded C.

The closest solution that I have found is in the following link: https://www.jonolick.com/home/mpeg-video-writer. However, this format is still too lossy and fast (24fps at the slowest).

1 ACCEPTED SOLUTION

Accepted Solutions
ZThat
Senior

The following link provides a library for how to create AVI files with bitmap data with a library completely independent of an OS. https://www.mikekohn.net/file_formats/libkohn_avi.php .

It is important to note that, when using this library, the FOURCC is required for whatever format you are using. If you are using bitmap file data with 24bpp RGB, you need to leave the FOURCC as all null. The internet would lead you to believe that you need to use "DIB ". DO NOT USE "DIB ". This FOURCC is not accepted by any mainstream media player and will leave you scratching your head for hours or days as to why your video won't play even though windows recognizes all of the data (such as video framerate, bitrate, etc.) If you simply provide no FOURCC, any media player will assume 24bpp inverted RGB888/RGB24. This is a great resource if you intend to save a series of bitmap images, or JPEGs as a video and you have no operating system on your embedded firmware. To give an idea of how much memory it uses, I am making videos from 400x400 RGB24 data, and 10 frames takes about 5MB. So a 2 minute video at 5FPS should be 300 MB. It comes with optional RLE as well, so you can probably cut that down.

View solution in original post

3 REPLIES 3

MJPEG ?

Tips, Buy me a coffee, or three.. PayPal Venmo
Up vote any posts that you find helpful, it shows what's working..
S.Ma
Principal

What is the resolution? seems important to know this first hand.

If your image is 24 bpp, shrink it with 5:6:5 16 bpp,

You can also try to use RLE minimalistic compression.

ZThat
Senior

The following link provides a library for how to create AVI files with bitmap data with a library completely independent of an OS. https://www.mikekohn.net/file_formats/libkohn_avi.php .

It is important to note that, when using this library, the FOURCC is required for whatever format you are using. If you are using bitmap file data with 24bpp RGB, you need to leave the FOURCC as all null. The internet would lead you to believe that you need to use "DIB ". DO NOT USE "DIB ". This FOURCC is not accepted by any mainstream media player and will leave you scratching your head for hours or days as to why your video won't play even though windows recognizes all of the data (such as video framerate, bitrate, etc.) If you simply provide no FOURCC, any media player will assume 24bpp inverted RGB888/RGB24. This is a great resource if you intend to save a series of bitmap images, or JPEGs as a video and you have no operating system on your embedded firmware. To give an idea of how much memory it uses, I am making videos from 400x400 RGB24 data, and 10 frames takes about 5MB. So a 2 minute video at 5FPS should be 300 MB. It comes with optional RLE as well, so you can probably cut that down.