The content of this page has been automatically translated by AI. If you encounter any problems while reading, you can view the corresponding content in Chinese.

Whiteboard Streaming Watch

Last updated: 2024-12-19 17:45:29

Note
Whiteboard stream recording relies on the cloud recording of TRTC. Enabling recording will incur corresponding recording costs. For specific billing rules, refer to Billing of On-Cloud Recording.

Whiteboard Stream Recording

The whiteboard stream service itself does not provide a recording feature, but you can use the cloud recording feature of the TRTC service to perform whiteboard stream recording.
TRTC cloud recording offers two recording modes: Global Auto Recording and Specified User Recording.

Global Auto Recording (Recommended)

In the Global Auto Recording mode of TRTC cloud recording, every user's audio and video upstream stream in each TRTC room will be automatically recorded. The start and stop of the recording task are automatic, requiring no additional effort, making it simple and easy to use. The whiteboard stream, as an upstream stream in the room, will also be automatically recorded.
Global Auto Recording configuration method:
1. Log in to the TRTC console, and select Application Management in the left navigation bar.
2. Click Application Management under Recording Management, click Global Auto Recording, and you will see the Global Auto Recording template.
3. In the settings page of the Global Auto Recording template, choose MP4 as the recording file format, and select other settings as needed.
4. Click the Submit button at the bottom, and then click the checkbox for Global Auto Recording.



5. For newly created applications: More settings for enabling TRTC cloud recording can be found on the TRTC Implement Cloud Recording and Playback page.

Specified User Recording

If you need fine control over the recording of each stream, such as which streams need to be recorded and which do not, selecting the Specified User Recording mode is more suitable for this scenario.
The configuration method of the Specified User Recording mode is similar to the Global Auto Recording mode. Just select the Specified User Recording option when choosing the cloud recording form.
When you have selected the Specified User Recording mode, extra work is needed to complete the recording:
1. If you need to record a user's single stream video, specify userDefineRecordId via the client SDK API when the user enters the room, indicating that the user's video stream needs to be recorded.
Sample on Android:
mTRTCCloud = TRTCCloud.sharedInstance(getApplicationContext());
mTRTCCloud.setListener(new TRTCCloudImplListener(this));

// Initialize and configure SDK parameters
TRTCCloudDef.TRTCParams trtcParams = new TRTCCloudDef.TRTCParams();
trtcParams.sdkAppId = GenerateTestUserSig.SDKAPPID;
trtcParams.roomId = Integer.parseInt(mRoomId);

// Modify these to actual UserID and UserSig
trtcParams.userId = "UserID to enter the room";
trtcParams.userSig = "Corresponding UserSig";

// Specify the recording ID. Recording will occur when a user enters the room. It needs to be changed to the actual desired string.
trtcParams.userDefineRecordId = "xxx";

// Enter the room as an anchor
trtcParams.role = TRTCRoleAnchor;

// Enter the call
mTRTCCloud.enterRoom(trtcParams, TRTC_APP_SCENE_VIDEOCALL);

// Enable local audio collection and upstream
mTRTCCloud.startLocalAudio();
// Enable local screen collection and upstream
mTRTCCloud.startLocalPreview(mIsFrontCamera, mLocalPreviewView);

// Set upstream video encoding parameters
TRTCCloudDef.TRTCVideoEncParam encParam = new TRTCCloudDef.TRTCVideoEncParam();
encParam.videoResolution = TRTCCloudDef.TRTC_VIDEO_RESOLUTION_640_360;
encParam.videoFps = Constant.VIDEO_FPS;
encParam.videoBitrate = Constant.RTC_VIDEO_BITRATE;
encParam.videoResolutionMode = TRTCCloudDef.TRTC_VIDEO_RESOLUTION_MODE_PORTRAIT;
mTRTCCloud.setVideoEncoderParam(encParam);

2. If you need to record a single stream video of whiteboard pushing, set the AutoRecord parameter to true when starting the whiteboard stream pushing, indicating that the whiteboard push stream needs to be recorded.
Go version sample code:
package main

import (
"fmt"

"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
tiw "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/tiw/v20190919"
)

func main() {
// Enter your real SecretID and SecretKey here
credential := common.NewCredential(
"YourSecretID",
"YourSecretKey",
)
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "tiw.tencentcloudapi.com"
client, _ := tiw.NewClient(credential, "ap-guangzhou", cpf)

request := tiw.NewStartWhiteboardPushRequest()

// Please replace with the actual SdkAppID and RoomID
request.SdkAppId = common.Int64Ptr(1400000001)
request.RoomId = common.Int64Ptr(880528)

// Please modify this to the actual UserID and UserSig
request.PushUserId = common.StringPtr("tic_push_user_880528_test")
request.PushUserSig = common.StringPtr("CorrespondingUserSig")

// Configure the width and height of the whiteboard video and the whiteboard initialization parameters
request.Whiteboard = &tiw.Whiteboard{
Width: common.Int64Ptr(1280),
Height: common.Int64Ptr(720),
InitParam: common.StringPtr("{\"ratio\": \"16:9\"}"),
}

// Whiteboard streaming provides backup streaming capability. If you need to push a backup stream, you need to provide another UserID and UserSig in the Backup parameter
request.AutoManageBackup = common.BoolPtr(true)
request.Backup = &tiw.WhiteboardPushBackupParam{
PushUserId: common.StringPtr("tic_push_user_880528_test_backup"),
PushUserSig: common.StringPtr("xxxx"),
}

// Set the automatic stop streaming timeout. Here, it is set to 300 seconds, which means that if no one operates the whiteboard for more than 300 seconds, the whiteboard streaming will automatically stop
request.AutoStopTimeout = common.Int64Ptr(300)

// Set AutoRecord to true, indicating that TRTC's cloud recording needs to record the whiteboard streaming video
request.AutoRecord = common.BoolPtr(true)

response, err := client.StartWhiteboardPush(request)
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
fmt.Printf("%s", response.ToJsonString())
}

3. If you need to record Mixed Stream Video, specify OutputParams.RecordId when Start On-Cloud MixTranscoding, meaning this stream needs to be recorded. Go version sample code:
package main

import (
"fmt"

"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/errors"
"github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/common/profile"
trtc "github.com/tencentcloud/tencentcloud-sdk-go/tencentcloud/trtc/v20190722"
)

func main() {

// Enter your real SecretID and SecretKey here
credential := common.NewCredential(
"YourSecretID",
"YourSecretKey",
)
cpf := profile.NewClientProfile()
cpf.HttpProfile.Endpoint = "trtc.tencentcloudapi.com"
client, _ := trtc.NewClient(credential, "ap-guangzhou", cpf)

request := trtc.NewStartMCUMixTranscodeRequest()

// Specify RecordId in OutputParams, indicating that this stream needs to be recorded. The string here can be changed to the desired one
request.OutputParams = &trtc.OutputParams{
RecordId: common.StringPtr("1400000001_880528_mix"),
}

// Specify mixed-stream audio and video encoding parameters, and adjust as needed
request.EncodeParams = &trtc.EncodeParams{
AudioSampleRate: common.Uint64Ptr(48000),
AudioChannels: common.Uint64Ptr(1),
AudioBitrate: common.Uint64Ptr(50),
VideoWidth: common.Uint64Ptr(1280),
VideoHeight: common.Uint64Ptr(720),
VideoBitrate: common.Uint64Ptr(500),
VideoFramerate: common.Uint64Ptr(20),
VideoGop: common.Uint64Ptr(3),
}

// Specify the mixed-stream layout, here we choose the predefined layout template 2 (screen sharing template), and set the large screen to display the whiteboard streaming video.
// Here we assume the user's whiteboard streaming ID is "tic_push_user_880528_test", please replace it with the actual whiteboard streaming user ID when in use
request.LayoutParams = &trtc.LayoutParams{
Template: common.Uint64Ptr(2),
MainVideoUserId: common.StringPtr("tic_push_user_880528_test"),
MainVideoStreamType: common.Uint64Ptr(0),
}

// Please replace with the actual SdkAppID and RoomID
request.SdkAppId = common.Uint64Ptr(1400000001)
request.RoomId = common.Uint64Ptr(880528)

response, err := client.StartMCUMixTranscode(request)
if _, ok := err.(*errors.TencentCloudSDKError); ok {
fmt.Printf("An API error has returned: %s", err)
return
}
if err != nil {
panic(err)
}
fmt.Printf("%s", response.ToJsonString())
}

For detailed TRTC Cloud recording configuration and usage methods, please refer to Enable cloud recording and playback.