|
美摄SDK For Android
2.5.0.22
|
在拍摄视频时,通过对视频进行抠像,然后运用美摄SDk的虚拟场景包(.capturescene)到视频上,即实现了虚拟直播功能。
具体实现流程如下:
m_streamingContext = NvsStreamingContext.init(this, null);
//给streaming context设置回调接口
m_streamingContext.setCaptureDeviceCallback(this);
m_streamingContext.getAssetPackageManager().setCallbackInterface(this);
//采集预览输出连接到NvsLiveWindow控件
m_streamingContext.connectCapturePreviewWithLiveWindow(m_liveWindow);
NvsCaptureVideoFx keyerFx = m_streamingContext.appendBuiltinCaptureVideoFx("Master Keyer");
if(keyerFx != null) {
//开启溢色去除
keyerFx.setBooleanVal("Spill Removal",true);
//将溢色去除强度设置为最低
keyerFx.setFloatVal("Spill Removal Intensity",0);
//设置收缩边界强度
keyerFx.setFloatVal("Shrink Intensity",0.4);
}
//需要对采集的视频进行颜色吸取操作,因此需要使用STREAMING_ENGINE_CAPTURE_FLAG_GRAB_CAPTURED_VIDEO_FRAME标志
m_streamingContext.startCapturePreview(0, NvsStreamingContext.VIDEO_CAPTURE_RESOLUTION_GRADE_HIGH,
NvsStreamingContext.STREAMING_ENGINE_CAPTURE_FLAG_GRAB_CAPTURED_VIDEO_FRAME, null);
NvsColor sampledColor = m_streamingContext.sampleColorFromCapturedVideoFrame(sampleRect);
//将吸取下来的背景画面颜色值设置给抠像特技
NvsCaptureVideoFx keyerFx = m_streamingContext.getCaptureVideoFxByIndex(0);
if(keyerFx) {
keyerFx.setColorVal("Key Color",sampledColor);
}
m_streamingContext.applyCaptureScene(sceneId);
1.8.11