tencent cloud


Recording to COS

Last updated: 2023-10-08 14:41:11
    With CSS, you can record a live stream and save the recording file to VOD or COS. This document shows you how to record to Cloud Object Storage (COS).


    To record to COS, you need to activate COS first. We recommend you buy a storage package in advance to avoid service suspension caused by overdue payments. For details, see COS > Getting Started.
    After enabling the recording feature, please make sure that your COS service is in normal status. If COS is not activated or is suspended due to overdue payments, live recording will fail. No recording files will be generated. Nor will fees be incurred.
    A recording file is available about five minutes after recording ends. For example, if you start recording a live stream at 12:00 and stop at 12:30, you can get the recorded video at around 12:35.
    After creating a recording template, you need to bind it to a push domain. For detailed directions, see “Recording Configuration”. The template takes effect 5-10 minutes after binding.
    Mixed-stream recording does not support mixing streams inside the Chinese mainland with streams outside. Doing so will cause an error and playback of the recording file will fail.
    CSS needs permissions to store recording files in COS. Before you use the record-to-COS feature, make sure you have granted the necessary permission. If recording to COS fails due to insufficient permissions, the video cannot be recovered. For how to grant the permission, see “Authorizing CSS to Store Recording Files in COS”.
    Due to the default traffic and QPS limits of COS storage buckets, if your estimated concurrent push streams exceed 5000, please Submit a Ticket to adjust the QPS limit to avoid affecting the normal use of your business.
    If you don’t specify a recording template when initiating a recording task, the recording file will be saved to VOD.


    You have activated CSS and added a push domain.
    You have activated COS.

    Creating a Recording Template

    1. Log in to the CSS console and select Feature Configuration > Live Recording on the left sidebar.
    2. Select Save to COS.
    3. Click Create template and complete the following settings:
    Template Name
    The template name, which can contain letters, digits, underscores (_), and hyphens (-).
    Template Description
    The template description, which can contain letters, digits, underscores (_), and hyphens (-).
    Recording Content
    Original stream
    The recording video records the original stream by default and retains its original bitrate. Record videos before transcoding, watermarking, and stream mixing. For WebRTC streams, please select other content types, because the audio playback may be not compatible.
    Watermarked stream
    Record videos after they are watermarked according to the specified watermark template. If no watermark template is configured, original streams will be recorded.
    Transcoded stream
    Record videos after they are transcoded according to the specified transcoding template. You can select an existing transcoding template or click the name of a template to modify its configuration. If the template configured is deleted, watermarked streams will be recorded.
    Recording Format
    Videos can be outputted in formats of HLS, MP4, FLV, and AAC (for audio-only recording).
    If you select Original stream, you cannot record the audio of WebRTC streams.
    You cannot record transcoded streams if you use the time shifting feature. If time shifting is enabled for a stream, the original stream will be recorded.
    If an audio-only transcoding template is selected, the recording format must also be an audio format.
    To record a transcoded live stream, you need to configure a transcoding task for the stream in advance. This will incur transcoding fees. Transcoding fees will be charged only once for playback of the same transcoded stream (same transcoding template).
    4. Select the recording content and formats and complete the following settings:
    Max Recording Time Per File (minutes)
    There is no upper limit on the length of a recording file in HLS format. If a live stream is interrupted and the timeout period for resumption elapses, a new recording file will be generated to continue recording. The value range for the maximum length of a recording file in FLV format is 1-720 minutes. The value range for the maximum length of a recording file in MP4 or AAC format is 1-120 minutes.
    Resumption Timeout (seconds)
    When the interruption interval of the live stream does not exceed the set resumption timeout period, only one file will be generated for a live stream. However, the recorded file will only be available after the resumption timeout period has expired. Please set the resumption timeout period reasonably.
    Only the HLS format supports recording resumption after push interruption, and the value range for the timeout period for resumption is 1-1800 seconds.
    Storage Period (days)
    You can select Permanent to save a recording file permanently or Custom to specify a storage period (up to 1,500 days). If you set the period to 0, recording files will be saved permanently.
    Storage path
    Select a bucket you created in COS. Make sure you have granted CSS access to this bucket. Region shows the region information of the selected COS bucket. It cannot be modified.
    Backup storage path
    In case of failure to save recording files to the primary storage path due to network jitter, the backup path will be used. After the primary path recovers, the recording files saved in the backup path will be automatically uploaded to the primary path. The backup and primary paths must be in different regions.
    The default storage folder is{RecordSource}/{Domain}/{AppName}/{StreamID}/{RecordId}/{StartYear}-{StartMonth}-{StartDay}-{StartHour}-{StartMinute}-{StartSecond}.
    {RecordSource}indicates the content type. If the original stream is recorded, this is "origin". If a transcoded stream is recorded, this is the transcoding template ID.
    {StartYear}indicates the starting year.
    {StartMonth}indicates the starting month.
    {StartDay}indicates the starting day.
    {StartMinute}indicates the starting minute.
    {StartSecond}indicates the starting second.
    {Domain}indicates the push domain.
    {AppName} indicates the push path.
    {StreamID} indicates the stream ID.
    {RecordId}indicates the recording task ID, which is returned by the CreateRecordTask API.
    「/」indicates folder levels. 「-」 is an ordinary character.
    5. Click Save.
    Streams are uploaded while being recorded, which is why the filename does not contain fields that indicate the end time.

    Binding a Domain Name

    1. Log in to the CSS console, select Feature Configuration > Live Recording on the left sidebar, and click Save to COS.
    Bind a domain to an existing template: Click Bind Domain Name in the top left.
    Bind a domain after creating a template: After creating a template, click Bind Domain Name in the dialog box that pops up.
    2. In the pop-up window, select a Recording template and a Push domain and then click Confirm.
    You can click Add to bind multiple push domains to a template.

    Unbinding a Domain Name

    1. Log in to the CSS console, select Feature Configuration > Live Recording on the left sidebar, and click Save to COS
    2. Select a recording template bound with domain names, find the target domain name, and click Unbind.
    3. In the pop-up window, click Confirm.
    Unbinding the recording template will not affect ongoing live streams.
    To cancel recording for ongoing streams, stop the streams and push them again.

    Modifying a Template

    1. Go to Feature Configuration > Live Recording and select Save to COS.
    2. Select the target recording template and click Edit on the right to modify the template information.
    3. Click Save.

    Deleting a Template

    1. Log in to the CSS console, select Feature Configuration > Live Recording on the left sidebar, and click Save to COS.
    2. Select the target recording template, and click Delete in the upper right.
    3. In the pop-up window, click Confirm.
    If domain names are bound to a template, you need to unbind them before you can delete the template.
    In the console, recording templates are managed at the domain level. To unbind recording rules bound to streams by APIs, call DeleteLiveRecordRule.


    You can also unbind and bind domains and recording templates on the Domain Management page. For details, see Recording Configuration.
    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support