如何从Quickblox iOS中的远程视频捕获视频帧

时间:2016-11-15 09:11:52

标签: objective-c webrtc quickblox

我想在运行时获取远程用户(远程流)的屏幕截图, 我试图通过远程视图将当前CurrentImageContext作为UIGraphicsBeginImageContextWithOptions(myRemoteView.bounds.size, myRemoteView.opaque, 0.0f)的{​​{1}}参数,但是在运行时捕获时我得到了空白屏幕,任何关于如何进行操作的线索这个问题? 我使用的是最新版本的Quickblox,ios 10和xcode 8。

当远程用户连接时,此方法称为回调,

  • (void)session:(QBRTCSession *)session receivedRemoteVideoTrack:(QBRTCVideoTrack *)videoTrack fromUser:(NSNumber *)userID {

    QBRTCVideoTrack * remoteVideoTrak = [self.session remoteVideoTrackWithUserID:@(user.ID)];     QBRTCRemoteVideoView * remoteVideoView = [[QBRTCRemoteVideoView alloc] init];     remoteVideoView.frame = self.remoteVV.bounds;

    [myRemoteView drawViewHierarchyInRect:myRemoteView.bounds afterScreenUpdates:YES]

}

我wana捕捉'self.remoteVV'作为截图,但它总是给我一个黑色的图像。

2 个答案:

答案 0 :(得分:0)

您可以尝试使用此代码在同一视频会议中拍摄远程流的屏幕截图。它对我有用。

UIGraphicsBeginImageContextWithOptions(self.bounds.size, NO, 2.0f);
        [self drawViewHierarchyInRect:self.bounds afterScreenUpdates:YES];
        UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();

答案 1 :(得分:0)

This helped me to capture the StreamView.

func captureScreen() -> UIImage? {
        guard let streamView = conferenceStreamView else { return nil }
        UIGraphicsBeginImageContextWithOptions(streamView.bounds.size, false, 0);
        streamView.drawHierarchy(in: streamView.bounds, afterScreenUpdates: true)
        let image: UIImage = UIGraphicsGetImageFromCurrentImageContext()!
        UIGraphicsEndImageContext()
        return image
    }
相关问题