tencent cloud

Mobile Live Video Broadcasting

Release Notes and Announcements
TUILiveKit Release Notes
Live SDK Release Notes
User Guide
Product Introduction
Overview
Strengths
Performance Statistics
Concepts
Purchase Guide
TRTC Live Billing Overview
Billing of Video Live Component
Activating the Service (TUILiveKit)
Free Demo
Demo
Run Demo(TUILiveKit)
Integration Guide
Video Live Streaming
Preparation
Host Live Streaming
Audience Viewing
Live Stream List Live Stream List
Voice Chat Room
Preparation
Host Live Streaming
Audience Viewing
Live Stream List
Live Streaming Kit
Live Streaming Kit(Electron Desktop Application)
Live Streaming Kit(Web Desktop Browser)
Live Broadcast Monitoring
Monitoring Webpage (Web Desktop Browser React)
Monitoring Webpage (Web Desktop Browser Vue)
UI Customization
Live Stream Video Component
Video Source Editing Canvas
Audience List Component
Barrage Component
Media Source Configuration Panel
Link Management Panel
Live Gift Component
No UI Integration
Video Live Streaming
Voice Chat Room
Feature Guide
Follow Anchors (TUILiveKit)
Ultimate Image Quality (TUILiveKit)
Push Media Stream Into Room (TUILiveKit)
Gift System (TUILiveKit)
Client APIs
Android
iOS
Web
Server APIs (TUILiveKit)
Account System
REST API
Third-Party Webhooks
Error Codes (TUILiveKit)
FAQs
Platform Compilation
User Authentication
Live SDK
Product Introduction
Purchase Guide
Free Demo
Free Trial License
SDK Download
Licenses
Advanced Features
Client API
FAQs
Integration (No UI)
API Documentation
OSS information
OSS Attribution Notice

LVB

포커스 모드
폰트 크기
마지막 업데이트 시간: 2024-11-18 20:26:09

Basics

This document introduces the live playback feature of the Video Cloud SDK.

Live streaming and video on demand

In live streaming, the video streams published by hosts in real time are the source of streaming. When hosts stop publishing streams, the video played stops. Since video is streamed in real time, players do not have progress bars when they play live streaming URLs.
In video on demand (VOD), video files in the cloud are the source of streaming. Videos can be played at any time as long as they are not deleted from the cloud, and the playback progress can be adjusted using the progress bar. Video streaming websites such as Tencent Video and Youku Tudou are typical applications of VOD.

Supported protocols

The table below lists the common protocols used for live streaming. We recommend FLV URLs (which start with http and end with flv) for LVB and WebRTC for LEB. For more information, please see LEB.
Protocol
Pro
Con
Playback Latency
HLS
Mature, well adapted to high-concurrency scenarios
SDK integration is required.
3s - 5s
FLV
Mature, well adapted to high-concurrency scenarios
SDK integration is required
2s - 3s
RTMP
Relatively low latency
Poor performance in high-concurrency scenarios
1s - 3s
WebRTC
Lowest latency
SDK integration is required
< 1s
Note:
LVB and LEB are priced differently. For details, please see LVB Billing Overview and LEB Billing Overview.

Notes

The Video Cloud SDK does not impose any limit on the sources of playback URLs, which means you can use it to play both Tencent Cloud and non-Tencent Cloud URLs. However, the player of the SDK supports only live streaming URLs in FLV, RTMP, HLS (M3U8), and WebRTC formats and VOD URLs in MP4, HLS (M3U8), and FLV formats.

Sample Code

Regarding frequently asked questions among developers, Tencent Cloud offers a straightforward API example project, which you can use to quickly learn how to use different APIs.
Platform
GitHub Address
iOS
Android
Flutter

Integration

Step 1. Download the SDK

Download the SDK and follow the instructions in SDK Integration to integrate the SDK into your application.

Step 2. Configure License Authorization for SDK

1. Obtain license authorization:
If you have obtained the relevant license authorization,need to Get License URL and License Key in Cloud Live Console.


If you have not yet obtained the license authorization,Please reference Adding and Renewing Licenses to make an application.
2. Before your App calls SDK-related functions (it is recommended in the Application class), set the following settings:
public class MyApplication extends Application {

@Override
public void onCreate() {
super.onCreate();
String licenceURL = ""; // your licence url
String licenceKey = ""; // your licence key
V2TXLivePremier.setEnvironment("GDPR"); // set your environment
V2TXLivePremier.setLicence(this, licenceURL, licenceKey);
V2TXLivePremier.setObserver(new V2TXLivePremierObserver() {
@Override
public void onLicenceLoaded(int result, String reason) {
Log.i(TAG, "onLicenceLoaded: result:" + result + ", reason:" + reason);
}
});
}
Note:
The packageName configured in the license must be the same as the application itself, otherwise the play stream will fail.

Step 3. Create a rendering view

For the player to display video images, you need to add a rendering view in the layout XML file:
<com.tencent.rtmp.ui.TXCloudVideoView
android:id="@+id/video_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:visibility="visible"/>

Step 4. Create a player object

The V2TXLivePlayer module in the Video Cloud SDK offers live playback capabilities. Use the setRenderView API to associate the module with the video_view control added to the UI in Step 3.
// mPlayerView is the view added in step 1
TXCloudVideoView mView = (TXCloudVideoView) view.findViewById(R.id.video_view);
// Create a player object
V2TXLivePlayer mLivePlayer = new V2TXLivePlayerImpl(mContext);
// Associate the player object with the view
mLivePlayer.setRenderView(mView);

Step 5. Start playback

String flvUrl = "http://2157.liveplay.myqcloud.com/live/2157_xxxx.flv";
mLivePlayer.startPlay(flvUrl);

Step 6. Change the fill mode

view: size and position You can modify the size and position of video images by adjusting the size and position of the video_view control added in Step3.
setRenderFillMode: aspect fill or aspect fit
Value
Description
V2TXLiveFillModeFill
Images are scaled to fill the entire screen, and the excess parts are cropped. There are no black bars in this mode, but images may not be displayed in whole.
V2TXLiveFillModeFit
Images are scaled as large as the longer side can go. Neither side exceeds the screen after scaling. Images are centered, and there may be black bars.
setRenderRotation: clockwise rotation of video
Value
Description
V2TXLiveRotation0
Original
V2TXLiveRotation90
Rotate 90 degrees clockwise
V2TXLiveRotation180
Rotate 180 degrees clockwise
V2TXLiveRotation270
Rotate 270 degrees clockwise
// Set the fill mode
mLivePlayer.setRenderFillMode(V2TXLiveFillModeFit);
// Set the rotation of video
mLivePlayer.setRenderRotation(V2TXLiveRotation0);





Step 7. Pause playback

Technically speaking, you cannot pause a live playback. In this document, by pausing playback, we mean freezing video and disabling audio. In the meantime, new video streams continue to be sent to the cloud. When you resume playback, it starts from the time of resumption. This is in contrast to VOD. With VOD, when you pause and resume playback, the player behaves the same way as it does when you pause and resume a local video file.
// Pause playback
mLivePlayer.pauseAudio();
mLivePlayer.pauseVideo();
// Resume playback
mLivePlayer.resumeAudio();
mLivePlayer.resumeVideo();

Step 8. Stop playback

Call stopPlay to stop playback.
mLivePlayer.stopPlay();

Step 9. Take a screenshot

Call snapshot to take a screenshot of the live video streamed. This method captures a frame of the streamed video. To capture the UI, use the corresponding API of the Android system.


mLivePlayer.setObserver(new MyPlayerObserver());
mLivePlayer.snapshot();
// Get the screenshot taken in the onSnapshotComplete callback of MyPlayerObserver
private class MyPlayerObserver extends V2TXLivePlayerObserver {
...
@Override
public void onSnapshotComplete(V2TXLivePlayer v2TXLivePlayer, Bitmap bitmap) {
}
...
}

Latency Control

The live playback feature of the SDK is not based on FFmpeg, but Tencent Cloud’s proprietary playback engine, which is why the SDK offers better latency control than open-source players do. We provide three latency control modes, which can be used for showrooms, game streaming, and hybrid scenarios.
Comparison of the three modes
Mode
Stutter
Average Latency
Scenario
Remarks
Speedy
More likely than the speedy mode
2 - 3s
Live showroom (Chongding Dahui)
The mode delivers low latency and is suitable for latency-sensitive scenarios.
Smooth
Least likely of the three
≥ 5s
Game streaming (Penguin Esports)
Playback is least likely to stutter in this mode, which makes it suitable for ultra-high-bitrate streaming of games such as PUBG.
Auto
Self-adaptive to network conditions
2 - 8s
Hybrid
The better network conditions at the audience end, the lower the latency.
Code to integrate the three modes
// Auto mode
mLivePlayer.setCacheParams(1.0f, 5.0f);
// Speedy mode
mLivePlayer.setCacheParams(1.0f, 1.0f);
// Smooth mode
mLivePlayer.setCacheParams(5.0f, 5.0f);
// Start playback after configuration
Note:
For more information on stuttering and latency control, see Video Stutter.

Listening for SDK Events

You can bind a V2TXLivePlayerObserver to your V2TXLivePlayer object to receive callback notifications about the player status, playback volume, first audio/video frame, statistics, warning and error messages, etc.

Periodically triggered notification

The onStatisticsUpdate callback notification is triggered every 2 seconds to update you on the player’s status in real time. Like a car’s dashboard, the callback gives you information about the SDK, such as network conditions and video information.
Parameter
Description
appCpu
CPU usage (%) of the application
systemCpu
CPU usage (%) of the system
width
Video width
height
Video height
fps
Frame rate (fps)
audioBitrate
Audio bitrate (Kbps)
videoBitrate
Video bitrate (Kbps)
The onPlayoutVolumeUpdate callback, which notifies you of the player’s volume, works only after you call enableVolumeEvaluation to enable the volume reminder. You can set the interval of the callback by specifying the intervalMs parameter of enableVolumeEvaluation.

Event-triggered notifications

Other callbacks are triggered when specific events occur.

도움말 및 지원

문제 해결에 도움이 되었나요?

피드백