비디오 모디파이어
비디오 모디파이어 기능을 사용하면 비디오 전송 전에 로컬 비디오 프레임을 수정할 수 있습니다. 이 기능을 통해 애플리케이션에서 실시간 이펙트, 필터 또는 변환을 송출 비디오 스트림에 적용할 수 있습니다.
| 지원되는 통화 유형 | 최소 SDK 버전 |
|---|---|
| 1대1 통화, 그룹 통화(컨퍼런스) | PlanetKit 7.0 |
Note
- 비디오 모디파이어는 카메라에서 캡처한 로컬 비디오에만 적용됩니다.
- 비디오 수정 처리 시 프레임 드롭 및 화질 저하를 방지하기 위해 연산 비용과 지연 시간을 최소화해야 합니다.
활용 사례
비디오 모디파이어의 주요 활용 사례는 다음과 같습니다.
- 실시간 비디오 이펙트 및 필터
- 뷰티 필터 및 얼굴 보정
- 색상 보정 및 조정
구현 단계
비디오 모디파이어 기능을 구현하려면 다음 단계를 따르세요.
비디오 모디파이어 구현
IVideoInterceptor를 상속하는 클래스를 만들어 비디오 프레임을 수정하세요.
#include "PlanetKit.h"
#include "IPlanetKitVideoInterceptor.h"
class VideoModifier : public PlanetKit::IVideoInterceptor {
public:
PlanetKit::SVideoFrame* ProcessVideoFrame(PlanetKit::SVideoFrame* pVideoFrame) override {
if (!pVideoFrame) {
return nullptr;
}
// Access video frame properties from SVideoFrame structure:
// - pVideoFrame->pbuffer: Pointer to the frame buffer
// - pVideoFrame->unBufferSize: Allocated buffer size
// - pVideoFrame->unDataLength: Actual length (in bytes) of buffer data
// - pVideoFrame->unWidth: Frame width in pixels
// - pVideoFrame->unHeight: Frame height in pixels
// - pVideoFrame->llTick: Tick count in microseconds
// - pVideoFrame->llTimeStamp: Timestamp
// - pVideoFrame->llDuration: Frame duration
// - pVideoFrame->eRotation: Rotation angle
// - pVideoFrame->bSubgroupMain: Whether frame belongs to main room
// - pVideoFrame->szSubgroupName: Subgroup name (if bSubgroupMain is false)
// Process the frame and apply your effects
// You can either:
// 1. Process synchronously: Modify the frame and return the pointer
// 2. Process asynchronously: Return nullptr and call delegate->onProcessFinished later
// Example: Apply your custom effect synchronously
ApplyVideoEffect(pVideoFrame);
// Return the modified frame pointer for synchronous processing
// Return nullptr if processing asynchronously (must register a delegate)
return pVideoFrame;
}
bool RegisterDelegate(PlanetKit::IVideoInterceptorDelegate* pDelegate) override {
m_pDelegate = pDelegate;
return true;
}
bool DeregisterDelegate() override {
m_pDelegate = nullptr;
return true;
}
private:
void ApplyVideoEffect(PlanetKit::SVideoFrame* pVideoFrame) {
// Implement your video effect logic here
// Note: This runs on the camera capture thread, keep processing lightweight
}
PlanetKit::IVideoInterceptorDelegate* m_pDelegate = nullptr;
};
비디오 모디파이어 설정
카메라 컨트롤러에 모디파이어를 등록하여 비디오 프레임 수정을 시작하세요.
// Get camera controller instance
PlanetKit::CameraControllerPtr pCameraController = PlanetKit::PlanetKitManager::GetInstance()->GetCameraController();
// Create and register the modifier
PlanetKit::IVideoInterceptorPtr pVideoModifier = PlanetKit::MakeAutoPtr<VideoModifier>();
bool success = pCameraController->RegisterVideoInterceptor(pVideoModifier);
if (!success) {
// Handle error
}
비디오 모디파이어 해제
모디파이어 등록을 해제하여 비디오 프레임 수정을 중단하세요.
PlanetKit::CameraControllerPtr pCameraController = PlanetKit::PlanetKitManager::GetInstance()->GetCameraController();
// Deregister the modifier
bool success = pCameraController->DeregisterVideoInterceptor();
if (!success) {
// Handle error
}
관련 API
비디오 모디파이어 기능과 관련된 API는 다음과 같습니다.