Issue Description
When previewing camera video locally on an Android TV box, the image is delayed by approximately 300 milliseconds compared to the real-time display. The device’s built-in camera app has minimal delay, but when previewing through the Agora SDK, the latency is noticeably higher.
Platform/SDK
Android TV Box, Agora RTC SDK
Solution and Root Cause
The delay occurs because the default video capture and encoding configuration in the Agora SDK is not optimized for certain Android TV box hardware. By adjusting specific private parameters and increasing the camera capture and streaming frame rate, video preview latency can be reduced significantly.
Step-by-Step Solution
-
Configure private parameters before initializing or joining the channel:
-
che.video.videoCodecIndex = 1
-rtc.video.enable_pvc = false
-che.video.android_camera_select = 0 -
Set the camera capture configuration to higher performance:
- Use
setCameraCaptureConfig(720P, 60fps)or alternatively usestartCameraCapturewith the same resolution and frame rate. -
Set the video encoder configuration to match:
-
setVideoEncoderConfig(720P, 30fps or 60fps)depending on your network and device performance. -
Adjust the stream resolution and bitrate configuration as needed:
- Low stream:
1280×720 @ 60fps, 300 kbps
- High stream:1280×720 @ 60fps, 1000 kbps
Result
After applying these settings, the local preview delay should decrease from approximately 300 ms to around 150 ms, providing a noticeably smoother and more responsive preview experience.