Starter Deal! First 3 month from only  $9.9 /month!
Starter Deal! First 3 month from only  $9.9 /month!
Grab It Now 
RTC Engine
  • Overview
  • Web
    • Run Sample Demo
    • SDK Quickstart
    • Basic Features
      • Screen Sharing
      • Live Streaming
      • Media Device
      • Audio Volume
      • Set Encoding Profile
      • Detect Network Quality
      • Detect Capabilities
    • Advance Features
      • Enable AI Denoiser
      • Enable Audio Mixer
      • Enable Watermark
      • Enable Beauty and Effects
      • Data Messages
      • Custom Capturing and Rendering
    • API List
    • Released Notes
    • Supported Platforms
    • Web FAQs
      • Optimize Multi-Person Video Calls
      • Handle Autoplay Restriction
      • Handle Firewall Restriction
      • Others
  • Android
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Newwork Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCStatistics
      • TRTCCloudListener
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Solution
      • Real-Time Chorus (TUIKaraoke)
        • Quick Integration
        • Implementation Steps
        • Song Synchronization
        • Lyric Synchronization
        • Vocal Synchronization
        • Mixing Stream Solution
        • TRTCKaraoke APIs
        • FAQs
    • Release Notes
  • iOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
    • Solution
      • Quick Integration
      • Implementation Steps
      • Song Synchronization
      • Lyric Synchronization
      • Vocal Synchronization
      • Mixing Stream Solution
      • TRTCKaraoke APIs
      • FAQs
    • Release Notes
  • macOS
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • TRTCCloud
      • TRTCCloudDelegate
      • TRTCStatistics
      • TXAudioEffectManager
      • TXBeautyManager
      • TXDeviceManager
      • Type Definition
      • Deprecated Interface
      • ErrorCode
      • Release Notes
    • Release Notes
  • Windows
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Setting Video Quality
      • 10.Rotating Videos
    • Testing Hardware Devices
    • Testing Network Quality
    • Custom Capturing and Rendering
    • Custom Audio Capturing and Playback
    • Client APIs
      • Overview
      • ITRTCCloud
      • ITRTCStatistics
      • TRTCCloudCallback
      • ITXAudioEffectManager
      • ITXDeviceManager
      • Type Definition
      • Deprecated Interface
      • Error Codes
    • Release Notes
  • Electron
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Flutter
    • Integration
      • 1.API Examples
      • 2.Importing the SDK
      • 3.Entering a Room
      • 4.Subscribing to Audio/Video Streams
      • 5.Publish Audio/Video Streams
      • 6.Exiting a Room
      • 7.Sensing Network Quality
      • 8.Enabling Screen Sharing
      • 9.Sharing Computer Audio
      • 10.Setting Video Quality
      • 11.Rotating Videos
    • Client APIs
      • Overview
      • Error Codes
  • Unity
    • Integration
      • 1.API Examples
      • 2Importing the SDK
    • Client APIs
      • Overview
      • Error Codes
  • Qt
    • Integration
      • 1.Importing the SDK
  • Overview
    • Overview
  • Concepts
  • Features
  • Performance Statistics
  • Pricing
    • RTC-Engine Packages
    • Billing of On-Cloud Recording
    • Billing of MixTranscoding and Relay to CDN
    • Billing Explanation for Subscription Package Duration
    • Billing of Monitoring Dashboard
    • Free Minutes
    • Pay-As-You-Go
  • FAQs
    • FAQs for Beginners
    • Migration Guide
      • Twilio Video to Tencent RTC
      • Billing
      • Features
      • UserSig
      • Firewall Restrictions
      • How to Downsize Installation Package
      • TRTCCalling for Web
      • Audio and Video Quality
      • Others
RTC Engine

11.Rotating Videos

Overview

Unlike the ubiquitous vertical screen experience of mobile live streaming, Tencent Real-Time Communication (TRTC) must accommodate both landscape and portrait viewing modes, thereby requiring extensive handling of screen orientation. This article primarily discusses:
The implementation of the portrait mode pattern, for instance: WeChat's video calling is a typical example of the portrait experience pattern.
The execution of the landscape mode pattern, for example: Multi-person audio-video room applications (like Little Fish Easy Connection) typically adopt the landscape mode pattern.
How to customize the control of the rotation direction and fill pattern for both local and remote images.




Supported Platforms

iOS
Android
Mac OS
Windows
Electron
Web
×

Portrait pattern

To realize a WeChat-like video call experience pattern, two tasks must be performed:

1. Configure the App's UI to display in portrait mode

iOS platform
Android platform
You can directly set this in XCode's General > Deployment Info > Device Orientation:


By setting the screenOrientation attribute of the activity to portrait, one can specify that this interface is in portrait pattern
<activity android:name=".trtc.TRTCMainActivity" android:launchMode="singleTask" android:windowSoftInputMode="adjustPan"
android:screenOrientation="portrait" />

2. Configuration SDK utilizing vertical screen resolution

Whilst utilizing the TRTCCloud's setVideoEncoderParam setting for video coding parameters, specifying videoResolutionMode as TRTC_VIDEO_RESOLUTION_MODE_PORTRAIT will suffice. Below is the exemplar code:
trtcCloud.setVideoEncoderParam(TRTCVideoEncParam( videoFps: 15, videoResolution: TRTCCloudDef.TRTC_VIDEO_RESOLUTION_640_360, videoBitrate: 600, videoResolutionMode: TRTCCloudDef.TRTC_VIDEO_RESOLUTION_MODE_PORTRAIT));

Landscape mode

If you wish for the App to have a landscape orientation experience, the work you need to carry out is similar to that of the portrait pattern. You simply need to adjust the parameters in the first and second steps accordingly. Specifically in the second step, the value of videoResolutionMode in TRTCVideoEncParam should be: TRTC_VIDEO_RESOLUTION_MODE_LANDSCAPE.

Tailored Control

The TRTC SDK provides interface functions to manipulate both the local and remote screen's rotation direction and fill pattern:
Interface Function
Functionality
Annotation Note
setVideoEncoderRotation
Establishing the clockwise rotation angle of the encoder output display
Supports rotation in two directions: 0 and 180 degrees clockwise

GSensorMode

Given the various compatibility issues involved in screen rotation, recording, and CDN live streaming, TRTC SDK only provides a simple gravity-sensing adaptive function. You can enable this via the setGSensorMode interface of TRTCCloud.
This function supports 90-degree, 180-degree and 270-degree rotation adaptation. That is, when the user's own phone rotates, the orientation of the image seen by others remains unchanged. Furthermore, this adaptation is based on adjustments to the encoder's direction. Therefore, recorded videos, as well as images viewed on mini-programs and H5 end, can maintain the original orientation.
Note:
Another implementation of gravity-sensing adaptation involves encoding the gravity direction of each video frame, and then adaptively adjusting the rendering direction at the end of the remote user. However, this embodiment requires the introduction of additional transcoding resources to solve the problem of keeping the direction of the recorded video consistent with the expected video direction. Therefore, it is not recommended.