비디오 모디파이어
비디오 모디파이어 기능을 사용하면 비디오 전송 전에 로컬 비디오 프레임을 수정할 수 있습니다. 이 기능을 통해 애플리케이션에서 실시간 이펙트, 필터 또는 변환을 송출 비디오 스트림에 적용할 수 있습니다.
| 지원되는 통화 유형 | 최소 SDK 버전 |
|---|---|
| 1대1 통화, 그룹 통화(컨퍼런스) | PlanetKit 7.0 |
Note
- 비디오 모디파이어는 카메라에서 캡처한 로컬 비디오에만 적용됩니다.
- 비디오 수정 처리 시 프레임 드롭 및 화질 저하를 방지하기 위해 연산 비용과 지연 시간을 최소화해야 합니다.
활용 사례
비디오 모디파이어의 주요 활용 사례는 다음과 같습니다.
- 실시간 비디오 이펙트 및 필터
- 뷰티 필터 및 얼굴 보정
- 색상 보정 및 조정
구현 단계
비디오 모디파이어 기능을 구현하려면 다음 단계를 따르세요.
비디오 모디파이어 구현
비디오 프레임을 수정하기 위해 PlanetKitVideoInterceptor 인터페이스를 구현하는 클래스를 만드세요.
import com.linecorp.planetkit.video.PlanetKitVideoInterceptor
import com.linecorp.planetkit.video.PlanetKitVideoFrameData
class VideoModifier : PlanetKitVideoInterceptor() {
override fun onFrameIntercept(data: PlanetKitVideoFrameData): PlanetKitVideoFrameData? {
// Access video frame properties
val width = data.width // Int: frame width in pixels
val height = data.height // Int: frame height in pixels
val format = data.format // PlanetKitVideoSourceFormat: frame format
val rotation = data.rotation // PlanetKitVideoRotation: rotation angle
val timestamp = data.timestamp // Long: timestamp in nanoseconds
val buffer = data.buffer // ByteBuffer: video frame data
val size = data.size // Int: size in bytes
val isMirrored = data.isMirrored // Boolean: whether frame is horizontally flipped
// Process the frame and apply your effects
// You can either:
// 1. Process synchronously: Modify the frame and return it
// 2. Process asynchronously: Return null and call onFrameProcessedListener later
// Example: Apply your custom effect synchronously
applyVideoEffect(buffer, width, height, format)
// Return the modified frame for synchronous processing
// Return null if processing asynchronously (must set onFrameProcessedListener)
return data
}
private fun applyVideoEffect(
buffer: ByteBuffer,
width: Int,
height: Int,
format: PlanetKitVideoSourceFormat
) {
// Implement your video effect logic here
// Note: This runs on the camera capture thread, keep processing lightweight
}
}
비디오 모디파이어 설정
비디오 프레임 수정을 시작하려면 카메라 매니저에 모디파이어를 등록하세요.
// Get camera manager instance
val cameraManager = PlanetKit.getCameraManager()
// Create and set the modifier
val videoModifier = VideoModifier()
cameraManager.setVideoSourceInterceptor(videoModifier)
비디오 모디파이어 해제
비디오 프레임 수정을 중단하려면 모디파이어 등록을 해제하세요.
val cameraManager = PlanetKit.getCameraManager()
// Clear the modifier by passing null
cameraManager.setVideoSourceInterceptor(null)
관련 API
비디오 모디파이어 기능과 관련된 API는 다음과 같습니다.