Capture Screenshots

Update time: 2025/06/11 16:45:39

In the middle of audio and video call, users can use the video capture function to capture and save real-time video streaming images as archives for analysis, memos of events, and evidence to be kept. In educational scenarios, for instance, students can capture and save the content of courseware or blackboard-writings as notes; in recreational scenarios, the video capture feature facilitates security review of the live streaming contents.

The NERTC SDK supports screen capturing of the real-time video streaming, including the local mainstream screen, local substream screen, remote mainstream screen and remote substream screen.

Considerations

  • The video capture function records real-time video streaming data only and the captured images will not contain watermark information of the canvas.
  • The timing for calling video capture-related APIs is specified as follows. If a video capture-related API is called in other circumstances, ERR_INVALID_OPERATION will be encountered, indicating that currently the operation is not supported.
    • The local mainstream video can be captured after startPreview / enableLocalVideo and

      joinChannel are successfully called.

    • The local substream video can be captured after startScreenCapture and joinChannel are successfully called.

    • The remote mainstream and substream video can be captured after the onUserVideoStart and onUserSubStreamVideoStart callbacks are triggered respectively.

Method

  1. Join a room and call a video capture-related API on demand to capture the video streaming.
    • When using takeLocalSnapshot for capturing local video streaming, you can specify to capture the mainstream or the substreams through the NERtcVideoStreamType parameter.
    • When using takeRemoteSnapshot for capturing remote video streaming, you can specify to capture the mainstream or the substreams through the NERtcVideoStreamType parameter.
  2. Obtain the captured file through callbacks

The video capture data is returned in the form of Bitmap through the onTakeSnapshotResult callback of the NERtcTakeSnapshotCallback class.

Sample code

//Local capture
NERtcEx.getInstance().takeLocalSnapshot(NERtcVideoStreamType.kNERtcVideoStreamTypeMain,
        new NERtcTakeSnapshotCallback() {
            @Override
            public void onTakeSnapshotResult(int errorCode, Bitmap image) {
                if(image == null) {
                    showToast("Local mainstream video capture failed!");
                } else {
                    showToast("Local mainstream video capture succeeded!");
                    saveBitmapToJpeg(user.userId,NERtcVideoStreamType.kNERtcVideoStreamTypeMain,image);
                }
            }
        });
   
//Remote video capture
NERtcEx.getInstance().takeRemoteSnapshot(user.userId, NERtcVideoStreamType.kNERtcVideoStreamTypeMain,
        new NERtcTakeSnapshotCallback() {
    @Override
    public void onTakeSnapshotResult(int errorCode, Bitmap image) {
        if(image == null) {
            showToast("Remote mainstream video capture failed uid: " + user.userId);
        } else {
            showToast("Remote mainstream video capture succeeded uid: " + user.userId);
            saveBitmapToJpeg(user.userId,NERtcVideoStreamType.kNERtcVideoStreamTypeMain,image);
        }
    }
});        
Was this page helpful?
Yes
No
  • Considerations
  • Method
  • Sample code