snapshotVideo method

Future<void> snapshotVideo(
  1. String? userId,
  2. int streamType,
  3. int sourceType,
  4. String path
)

视频画面截图

此 API 可对本地、远程主流或远程辅流图像进行截图。

参数:

userId:用户 ID。null 表示对本地视频进行截图。对于本地视频,仅支持截取摄像头图像(TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG)。

streamType:视频流类型。支持摄像头图像(TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG)和屏幕共享图像(TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_SUB)。

path:此路径必须精确到文件名和扩展名。扩展名决定了图像的格式。目前支持的格式包括 PNG、JPG 和 WEBP。例如,如果指定的路径为 path/to/test.png,则将生成 PNG 图像。请指定具有读/写权限的有效路径,否则无法生成图像文件。

不支持:

  • web

Implementation

Future<void> snapshotVideo(
  String?
      userId, // User ID. `null` indicates to screencapture the local video. For the local video, only the camera image (TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG) can be screencaptured.
  int streamType, // Video stream type. Camera image (TRTCCloudDef.TRTC_VIDEO_STREAM_TYPE_BIG) and screen sharing image (TRTCCloudDef#TRTC_VIDEO_STREAM_TYPE_SUB) are supported.
  int sourceType, // 0-stream  1-view
  String path, // Screenshot storage address
) {
  return _channel.invokeMethod('snapshotVideo', {
    "userId": userId,
    "streamType": streamType,
    "path": path,
    "sourceType": sourceType
  });
}