TRTCVideoEncParam

TRTCVideoEncParam

Video encoding parameters

Constructor

new TRTCVideoEncParam(videoResolution, resMode, videoFps, videoBitrate, minVideoBitrate, enableAdjustRes)

These settings determine the quality of image viewed by remote users as well as the image quality of recorded video files in the cloud.

Parameters:
Name Type Description
videoResolution TRTCVideoResolution required

[Field description] video resolution
[Recommended value]
- For mobile video call, we recommend you select a resolution of 360x640 or below and select Portrait (portrait resolution) for resMode.
- For mobile live streaming, we recommend you select a resolution of 540x960 and select Portrait (portrait resolution) for resMode.
- For desktop platforms (Windows and macOS), we recommend you select a resolution of 640x360 or above and select Landscape (landscape resolution) for resMode. [Note] to use a portrait resolution, please specify resMode as Portrait; for example, when used together with Portrait, 640x360 represents 360x640.

resMode TRTCVideoResolutionMode required

[Field description] resolution mode (landscape/portrait)
[Recommended value] for mobile platforms (iOS and Android), Portrait is recommended; for desktop platforms (Windows and macOS), Landscape is recommended.
[Note] to use a portrait resolution, please specify resMode as Portrait; for example, when used together with Portrait, 640x360 represents 360x640.

videoFps Number required

[Field description] video capturing frame rate
[Recommended value] 15 or 20 fps. If the frame rate is lower than 5 fps, there will be obvious lagging; if lower than 10 fps but higher than 5 fps, there will be slight lagging; if higher than 20 fps, the bandwidth will be wasted (the frame rate of movies is generally 24 fps).
[Note] the front cameras on certain Android phones do not support a capturing frame rate higher than 15 fps. For some Android phones that focus on beautification features, the capturing frame rate of the front cameras may be lower than 10 fps.

videoBitrate Number required

[Field description] target video bitrate. The SDK encodes streams at the target video bitrate and will actively reduce the bitrate only in weak network environments.
[Recommended value] please see the optimal bitrate for each specification in TRTCVideoResolution. You can also slightly increase the optimal bitrate. For example, TRTCVideoResolution_1280_720 corresponds to the target bitrate of 1,200 Kbps. You can also set the bitrate to 1,500 Kbps for higher definition.
[Note]you can set the videoBitrate and minVideoBitrate parameters at the same time to restrict the SDK's adjustment range of the video bitrate:
- If you want to "ensure clarity while allowing lag in weak network environments", you can set minVideoBitrate to 60% of videoBitrate. - If you want to "ensure smoothness while allowing blur in weak network environments", you can set minVideoBitrate to a low value, for example, 100 Kbps. - If you set videoBitrate and minVideoBitrate to the same value, it is equivalent to disabling the adaptive adjustment capability of the SDK for the video bitrate.

minVideoBitrate Number required

[Field description] minimum video bitrate. The SDK will reduce the bitrate to as low as the value specified by minVideoBitrate to ensure the smoothness only if the network conditions are poor. [Recommended value] you can set the videoBitrate and minVideoBitrate parameters at the same time to restrict the SDK's adjustment range of the video bitrate:
- If you want to "ensure clarity while allowing lag in weak network environments", you can set minVideoBitrate to 60% of videoBitrate. - If you want to "ensure smoothness while allowing blur in weak network environments", you can set minVideoBitrate to a low value, for example, 100 Kbps. - If you set videoBitrate and minVideoBitrate to the same value, it is equivalent to disabling the adaptive adjustment capability of the SDK for the video bitrate. [Note]default value: 0, indicating that a reasonable value of the lowest bitrate will be automatically calculated by the SDK according to the resolution you specify.

enableAdjustRes Boolean required

[Field description] whether to allow dynamic resolution adjustment. Once enabled, this field will affect on-cloud recording.
[Recommended value] this feature is suitable for scenarios that don't require on-cloud recording. After it is enabled, the SDK will intelligently select a suitable resolution according to the current network conditions to avoid the inefficient encoding mode of "large resolution + small bitrate".
[Note] default value: false. If you need on-cloud recording, please do not enable this feature, because if the video resolution changes, the MP4 file recorded in the cloud cannot be played back normally by common players.