The recording and playback features allow you to record live streams and play them to users on demand.
Your application may have a relatively small number of hosts at the early stage. Playback can enrich the content your application provides to audience at this stage. Even after your hosts grow to a considerable scale, having a library of high-quality content is still essential. Videos of past streams also make up an important part of a host’s profile.
The recording and playback features are built on Tencent Cloud's VOD service. Therefore, to use the recording feature, you need to activate VOD in the console. After that, you can find recorded videos in Video Management of the VOD console.
Follow the steps below to enable the recording feature.
Note:
- You can record live streams using an API. For more information, see CreateRecordTask.
- Recorded videos are automatically stored in the VOD platform. Therefore, to use the recording feature, you need to activate VOD and purchase storage and traffic packages to store and play back recorded videos. For more information, see Getting Started.
In the CSS console, go to Feature Configuration > Live Recording and click Create Recording Template. After configuration, click Save. For detailed instructions, please see the "Creating a Recording Template" section in CSS Recording.
Item | Description | ||
---|---|---|---|
Max Recording Time Per File |
|
||
Resumption Timeout | Only the HLS format supports recording resumption after interruption, and the timeout period for resumption can be set between 0 and 1800 seconds. | ||
Storage Period (day) | You can select Permanent to save a recording file permanently or Custom to specify a storage period (up to 1,500 days). Setting the period to `0` means to save recording files permanently. | ||
VOD Subapplication/Category | By default, streams are recorded to the primary application in VOD. You can also record them to a category of a writable subapplication. | ||
Advanced Configuration | Storage Policy | Select STANDARD_IA (cold storage) if the recording files will not be accessed frequently or will be stored for a long period of time, and select STANDARD (default) if the recording files need to be played back for business purposes.
|
|
VOD Task Flow | Click Select to bind a task flow created under the VOD subapplication. You can also click a task flow to go to the VOD console, where you can modify the task flow or create new ones. The bound task flow will be executed on recording files upon generation, for which you will be charged VOD fees. |
After creating a recording template, in the CSS console, select Domain Management, click a publishing domain to go to the details page, select Template Configuration, click Edit in the Recording Configuration section to bind the domain name to the template created, and click save. For detailed directions, please see Binding a Template with Domain Names.
Playback URLs are generated for new recording files. You can use them to enable various additional features for your application based on your business needs.
For example, you can add the playback URLs of a host’s past live streams to his or her profile. You can also select high-quality content from past live streams and recommend it to your users in a playback list.
There are two methods to get recording files.
Register a callback URL on your server and provide it when configuring callbacks with Tencent Cloud. Tencent Cloud will notify you of the generation of new recording files via the URL.
In the CSS console, select Event Center > Live Stream Callback, click Create Callback Template, fill in the callback information, and click Save. For detailed directions, see Creating a Callback Template.
Binding a domain name to the template
After creating a callback template, select Domain Management, click a publishing domain name to go to the details page, select Template Configuration, click Edit in the Callback Configuration section to bind the domain name to the template created, and click Save.
Below is a typical notification message. It indicates that a new FLV recording file with the ID 9192487266581821586
has been generated, and the playback URL is http://200025724.vod.myqcloud.com/200025724_ac92b781a22c4a3e937c9e61c2624af7.f0.flv
.
{
"channel_id": "2121_15919131751",
"end_time": 1473125627,
"event_type": 100,
"file_format": "flv",
"file_id": "9192487266581821586",
"file_size": 9749353,
"sign": "fef79a097458ed80b5f5574cbc13e1fd",
"start_time": 1473135647,
"stream_id": "2121_15919131751",
"t": 1473126233,
"video_id": "200025724_ac92b781a22c4a3e937c9e61c2624af7",
"video_url": "http://200025724.vod.myqcloud.com/200025724_ac92b781a22c4a3e937c9e61c2624af7.f0.flv"
}
Recording files are saved automatically in the VOD system after generation. You can view recording files in the VOD console or query files using a VOD API. For details, please see Obtaining Recording Files.
After you enable recording for a live stream, each audio/video frame published from the host’s mobile phone will be relayed to the recording system and written into a recording file.
When a live stream is interrupted, the access layer will immediately ask the recording server to wrap up the writing process, save the file generated to the VOD system, and generate an index for the file. You can then find the recording file in the VOD system. If you have configured recording callback, the recording system will send the index ID and playback URL to the server you specified.
If a file is too large, errors may occur while the file is being transferred and processed in the cloud. As a result, to ensure the success of recording, we have capped the duration of a single recording file at 120 minutes. You can record shorter video segments by setting the RecordInterval
parameter to a smaller value.
RecordInterval
parameter of the CreateLiveRecordTemplate API.RecordInterval
and is not interrupted, only one recording file will be generated.RecordInterval
, the stream will be segmented based on the duration specified by RecordInterval
. The purpose of this is to reduce the uncertainty of a file’s transfer time in a distributed system.Tencent Cloud as a PaaS provider does not really know how you define a live stream. Assume that a host streamed for 20 minutes, but the process was interrupted twice, once due to network change and once manually by the host. Is it one live stream or three?
In most mobile live streaming scenarios, we consider the period between the two time points below as a live stream.
If you use the above standard, the time information provided by your application is important. To determine which live stream a recording file belongs to, just search for the recording notification received by live stream code and time. Each recording notification carries information including stream ID, start time, and end time.
You can splice video segments using a cloud API.
Was this page helpful?