Raw video processing
In certain scenarios, it may be necessary to process raw video captured through the camera and microphone to achieve desired functionality or enhance the user experience. Video SDK provides the capability to pre-process and post-process the captured video data, allowing for the implementation of custom playback effects.
Understand the tech
Video SDK enables you to pre-process the captured video frames before sending the data to the encoder or perform post-processing on the received video frames after sending the data to the decoder.
The following figure shows the video data processing flow in the SDK video module.
- Position (2) corresponds to the
onCaptureVideoFrame
callback. - Position (3) corresponds to the
onPreEncodeVideoFrame
callback. - Position (4) corresponds to the
onRenderVideoFrame
callback.
Prerequisites
Ensure that you have implemented the SDK quickstart in your project.
Implement raw video processing
To implement raw video data functionality in your project, refer to the following steps:
-
Before joining the channel, create an
IVideoFrameObserver
object and register the video observer by calling theregisterVideoFrameObserver
method. -
Implement the
onCaptureVideoFrame
andonRenderVideoFrame
callbacks. After obtaining the video data, process it according to your specific scenario.CautionWhen modifying parameters in a
VideoFrame
, ensure that the updated parameters match the actual video frame in the buffer. Mismatches may cause issues like unexpected rotation, distortion, or other visual problems in the local preview and the remote video.
Reference
This section contains content that completes the information on this page, or points you to documentation that explains other aspects to this product.
Sample project
Agora provides an open source sample project ProcessRawData on GitHub. Download it or view the source code for a more detailed example.