The Multi-Media Abstraction Layer (MMAL) library provided by Broadcom is not documented, so it's nearly impossible to understand how to use it. Furthermore, it's a library that wraps all the OpenMAX IL specification, so if you simply need to record an H.264 video like in this example, you can just ignore that extra layer and talk directly to OpenMAX IL. Once you understand OpenMAX IL, it's affordable to try to write your own programs without MMAL. In other words, if you are new to the OpenMAX world, it's better to learn OpenMAX IL than MMAL, which is not documented and only works with Broadcom devices.
This example records a 3 second video in H.264 format. The components involved are: camera
, video_encode
and null_sink
.
If you want to play the video, you'll need to wrap it with a container format (some video players couldn't require this step), e.g. Matroska. You can download Matroska tools from here. Then, convert the H.264 file to a Matroska file:
$ mkvmerge --default-duration 0:25p -o video.mkv video.h264
Where 25p
is the encoding framerate of the h264 video. For example, if you record 640x480 @30fps, then you should encode the matroska file with --default-duration 0:30p
.
Build steps:
- Download and install the
gcc
andmake
programs. - Download this repository.
- Compile and execute:
make && ./h264
Useful documentation: