CM H264 Encode Pre-Record
The cmPrerecH264 is an h264 encoder with a cache that is used to encode the video/x-raw(YUV) data to video/h264(H264) data by the gstvideo4linux2 library. It supports set cache duration in second for the codec data, mainly used for MP4 records. This is designed for pre-recording.
API Instructions
create/destroy
gpointer cm_prerec_h264_create();
void cm_prerec_h264_destroy(gpointer hd);
start/stop
void cm_prerec_h264_start(gpointer hd);
void cm_prerec_h264_stop(gpointer hd);
parameters
/* @duration Cache time in seconds*/
void cm_prerec_h264_set_duration(gpointer hd, guint64 duration );
/* @return Encode output format, "video/h264,..." */
const char* cm_prerec_h264_get_caps_str(gpointer hd);
data
The encoder needs to know the actual format of the input before encoding, so must ensure the source is ready to be linked(the media info is ready).
Demo
Mp4 PreRecord Demo
Structure
Get raw data and use prerecord to encode, then start the mp4 record 3s later.
Main codes
For more details please refer to the demo file.
Test result
The mp4 file can be displayed on the PC, it contains pre-recorded data for about 4s.
Â