You can encode your image buffers to H.264 format or uncompressed video. The Camera library provides the necessary codecs to encode and decode image buffers to and from H.264 format and uncompressed formats.
... ... bool maxMin; int numSupported; int *supportValues = NULL; camera_handle_t cameraHandle; camera_videocodec_t videoCodec; supportedValues int x=0; // Connect to the camera, set the viewfinder mode, and start the viewfinder camera_open(CAMERA_UNIT_1, CAMERA_MODE_RW | CAMERA_MODE_ROLL, &cameraHandle); camera_set_vf_mode(cameraHandle, CAMERA_VFMODE_VIDEO); camera_start_viewfinder(cameraHandle, NULL, NULL, NULL); //check that video encoder configuration supports H.264 camera_get_video_property(cameraHandle, CAMERA_IMGPROP_VIDEOCODEC, &videoCodec); if (videoCodec != CAMERA_VIDEOCODEC_H264) { printf("No video encoder configuration supported for selected codec\n"); } // Retrieve configured parameters on the camera camera_get_videoencoder_parameter(handle, CAMERA_H264AVC_BITRATE, &bitrate, CAMERA_H264AVC_KEYFRAMEINTERVAL, &kfi, CAMERA_H264AVC_SLICETYPE, &sliceType, CAMERA_H264AVC_SLICESIZE, &sliceSize, CAMERA_H264AVC_PROFILE, &profile, CAMERA_H264AVC_LEVEL, &level, CAMERA_H264AVC_ENTROPYCODING, &entropy, CAMERA_H264AVC_RATECONTROL,&rateControl, CAMERA_H264AVC_QPI, &qpI, CAMERA_H264AVC_QPP, &qpP); // Call it the first time to determine number of supported bitrates camera_get_supported_videoencoder_parameter_values(cameraHandle, CAMERA_H264AVC_LEVEL, 0, &numSupported, NULL, &maxMin); // Allocate memory so that the valid values can be populated supportedValues = (int*) malloc(sizeof(int) * numSupported); // Call it a second time to retrieve the list of values if (camera_get_supported_videoencoder_parameter_values(cameraHandle, CAMERA_H264AVC_LEVEL, numSupported, &numSupported, supportedValues, &maxMin)!= EOK) { for(x=0; x < numSupported; ++x) { printf("\t Enumerator Value: %d", supportedValues[x]); } } //Pick some value and then set it. For example, we'll choose the first one. camera_set_videoencoder_parameter(cameraHandle, CAMERA_H264AVC_LEVEL, supportedValues[0]); //Start encoding and use a callback to call a function that keeps tracks of stats for the camera camera_start_encode(cameraHandle[i], NULL, encodedVideoCallback, NULL, NULL, (void*)i); ... ... // Do something while you are waiting wait(2000); camera_stop_encode(cameraHandle); ... ... //Close viewfinder and then disconnect from the camera wait(2000); camera_stop_viewfinder(cameraHandle); camera_close(cameraHandle); /* * Encoded video callback - called with encoded video frames */ void encodedVideoCallback(camera_handle_t handle, camera_buffer_t* buffer, void *arg) { // Print first encoded frame received and keep stats int cameraInst = (int) arg; if (cameraInst < MAX_SIMULTANEOUS_CAMERAS) { if (encodingInfo[cameraInst].numFrames == 0) { printf("Camera %d: first encoded frame of %lld bytes key %d rate %lld\n", cameraInst + 1, buffer->framedesc.compvid.bufsize, buffer->framedesc.compvid.keyframe, buffer->framedesc.compvid.bitrate); } encodingInfo[cameraInst].numFrames++; if (buffer->framedesc.compvid.keyframe) { encodingInfo[cameraInst].numKeyFrames++; } } } ... ...
... ... bool maxMin; int numSupported; int *supportValues = NULL; camera_handle_t cameraHandle; supportedValues int x=0; // Connect to the camera, set the viewfinder mode, and start the viewfinder camera_open(CAMERA_UNIT_1, CAMERA_MODE_RW | CAMERA_MODE_ROLL, &cameraHandle); camera_set_vf_mode(cameraHandle, CAMERA_VFMODE_VIDEO); camera_start_viewfinder(cameraHandle, NULL, NULL, NULL); // Retrieve the current bitrate setting on the camera. T camera_get_videoencoding_parameter(cameraHandle, CAMERA_H264AVC_BITRATE, &bitrate); // Call it the first time to determine number of supported bitrates camera_get_supported_videoencoder_parameter_values(cameraHandle, CAMERA_H264AVC_BITRATE, 0, &numSupported, NULL, &maxMin); // Allocate memory so that the valid values can be populated supportedValues = (int*) malloc(sizeof(int) * numSupported); // Call it a second time to retrieve the list of values if (camera_get_supported_videoencoder_parameter_values(cameraHandle, CAMERA_H264AVC_BITRATE, numSupported, &numSupported, supportedValues, &maxMin)!= EOK) { for(x=0; x < numSupported; ++x) { printf("\t Enumerator Value: %d", supportedValues[x]); } } //Pick some value and then set it. For example, we'll choose the first one for this example. camera_set_videoencoder_parameter(cameraHandle, CAMERA_H264AVC_BITRATE, supportedValues[0]); ... ... // Go and encode your video ... ...