tencent cloud

Feedback

SCF + TRTC for One-Stop Panoramic Recording

Last updated: 2022-01-23 16:20:59

    Use Cases

    Quick playback file generation

    Live stream playback can increase the value and reduce the production costs of high-quality resources to boost the profits. The panoramic recording feature can record the class content from user's perspective in real time, quickly transcode the content based on the massive serverless computing power pool after a class ends, and generate the recording file for playback instantly.

    Highlight collection

    Parents seldom have time to watch entire class videos of their children. The highlight collection feature renders the moments of children's excellent performance during the class to parents to improve their perception and recognition of the class. You can clip highlights from class recording files on the HTML5 platform, use panoramic recording to generate MP4 files, create a collection of highlight moments of children in class, and quickly distribute them through CDN.

    File composition

    General file composition requires transcoding, which consumes a lot of computing power. With SCF + TRTC, you can compose videos, audios, images, etc. on the same frontend page, adjust the layout, perform panoramic recording, decode multiple streams, and encode all of them into one stream to quickly generate video files, giving full play to computing power resources.

    How It Works

    Tencent Cloud's proprietary panoramic recording feature allows you to record videos in a WYSIWYG way. You only need to provide an accessible public network URL, and the feature can use Chrome for page rendering and recording, perform FFmpeg transcoding, and directly upload videos to COS to generate recording files in real time. Together with other Tencent Cloud products such as CSS, VOD, and TRTC, this offers a one-stop solution for education, gaming, and interactive entertainment scenarios.

    Application Strengths

    • Lower costs
      Panoramic recording uses Chrome for multi-stream decoding and one-stream encoding, which reduces computing power consumption and lowers the cost by over 60% compared with traditional recording solutions.
    • High fidelity
      Panoramic recording can capture all external information such as special effects in class on the client, fully retaining the in-person class experience.
    • Free switch
      During panoramic recording, you can flexibly adjust the browser layout and switch between teacher and student views.
    • Ultra high concurrency
      SCF computing instances can be quickly started to stably sustain high concurrency and handle business traffic spikes with ease.
    • Instant output
      Panoramic recording allows you to directly get the recording file for playback once the live stream ends, with no need to perform complex composition, which is time-saving and efficient.

    Application Resources

    After panoramic recording is deployed, the following resources will be created:

    • SCF function: it gets the external link data and uses panoramic recording to record videos in real time.
    • CLS log: it stores video processing logs and may incur fees. For more information, see CLS Billing Rules.
    • API Gateway: you can use an API Gateway trigger to trigger events.

    Prerequisites

    1. Configure and deploy account permissions as detailed in Account and Permission Configuration.
    2. Configure execution role permissions.
    3. Panoramic recording needs to be used together with other services, so you must add the following policies: QcloudRedisFullAccess, QcloudVPCFullAccess, QcloudCFSFullAcces, QcloudSCFFullAccess, QcloudCOSFullAccess, and QcloudAccessForScfRole. For more information, see Policy.

    Directions

    Creating dependency resources

    The following components are required as dependencies during function creation and must be created in advance: VPC, CFS file system or COS bucket, and TencentDB for Redis instance. For detailed directions on how to create them, see Building up an IPv4 VPC, Creating File Systems and Mount Targets, Getting Started with the Console, and Creating TencentDB for Redis Instances respectively.

    Creating panoramic recording application

    1. Log in to the Serverless console and select Serverless Application on the left sidebar.
    2. On the Serverless Application page, click Create Application.
    3. On the Create Application page, configure as prompted.
      • Creation method: select Template.
      • Fuzzy search: enter "panoramic", search, and select Panoramic recording .
        Click Learn More in the template to view relevant information in the Template Details pop-up window, which can be downloaded.
    4. Click Next and configure the related information .
      • Application Name: enter a name such as "record-app".
      • Region: select a region such as "Shanghai".
      • Intermediate Result Storage: select the storage position of temporary files during recording. You can select COS or CFS as needed.
      • Target Storage: select the final storage position of recording results. You can select VOD or COS as needed.
      • File System: select as needed.
      • Redis: select as needed.
    5. Click Complete.
      If you want to modify function configuration based on your business scenario, do so in Serverless Application > Resource List > Function Details as shown below:
      Note
      • If the recording application needs to rely on the prolonged function execution capability, configure as instructed in Async Execution.
      • To avoid request timeout, we recommend you set the backend timeout period of the API Gateway trigger to a large value or use the default value. For more information, see Provisioned Concurrency.

    API use instructions

    Prerequisites

    • Prepare a webpage that can be visited through a URL and is compatible with Chrome as the recording content source.
    • You should handle the possible login status or authentication on the page to be recorded by yourself.
    • If multimedia needs to be played back on the page to be recorded, you should handle multimedia operations such as playback, redirect, and stop by yourself.
    • The page to be recorded must display the complete content within the specified width and height with no scrollbars, as web panoramic recording can record only the visible area of the browser window but cannot record the content outside this area.

    API request path

    1. Log in to the Serverless console and select Serverless Application on the left sidebar.
    2. On the serverless application list page, click the target application name.
    3. On the application details page, get the trigger access entry as shown below:

    Recording start API

    This API is used to start panoramic recording. Parameters such as recording URL, resolution, and result callback address need to be specified in API parameters.

    ParameterTypeRequiredDescription
    ActionstringYesRequested operation type. To start recording, set it to Start.
    DataobjectYesRequest protocol parameter.
    RecordURLstringYesAccess URL of the webpage to be recorded. It must be accessible in Chrome.
    ManualStartboolYesWhether the recording task to be created can start after the page actively calls the window.startRecord method to trigger recording. The default value is false, indicating that the recording task will start automatically. If the value is set to true, after the recording function loads the page, it will not automatically start recording but will trigger recording after the page actively calls the window.startRecord method.
    WidthnumberNoRecording image width, which is 1280 by default. Value range: 0–2560.
    HeightnumberNoRecording image height, which is 720 by default. Value range: 0–2560.
    CallbackURLstringNoCallback address for recording result notification
    MaxDurationLimitintNoMaximum recording duration in seconds. Value range: 0–36000s. Default value: 21600s (6 hours). You need to configure a permanent key if this value exceeds 6 hours.
    StorageTypestringNoStorage position of the intermediate state webm file during recording. Valid values: cos and cfs. Default value: cfs. (If the COS_BUCKET_RAW parameter is configured in the environment variables, data will be written into the bucket; otherwise, data will be written to the raw path in the target bucket.)
    OutputobjectNoRequest protocol parameter.
    CosobjectNoRequest protocol parameter.
    DomainstringNoRecording file playback domain name. If it is not set, it will be the origin server domain name by default.
    BucketstringNoRecording file storage bucket. If it is not set, it will be the storage bucket set during function creation by default.
    RegionstringNoRecording file storage region. If it is not set, it will be the region of the storage bucket by default.
    TargetDirstringNoRecording file storage path. If it is not set, it will be Taskid by default.
    TargetNamestringNoRecording filename. If it is not set, it will be the stop timestamp by default.
    VodobjectNoVOD configuration parameter.
    MediaInfoobjectNoVOD media asset information.
    MediaNamestringNoMedia asset name.
    ExpireTimeTimestamp ISO8601NoExpiration time of media asset file in ISO 8601 format. For more information, see ISO date format.
    StorageRegionstringNoUpload region. This is only applicable to users who have special requirements for the upload region.
    ClassIdIntegerNoCategory ID, which is used to categorize the media asset for management. A category can be created and its ID can be obtained by using the CreateClass API.
    SourceContextstringNoSource context of up to 250 characters, which is used to pass through the user request information and will be returned by the VOD upload completion callback.
    ProcedureInfoobjectNoTask flow information
    ProcedurestringNoSubsequent task operation on a media asset file, i.e., after a media asset file is uploaded, task flow operations will be initiated automatically. This parameter value is a task flow template name. VOD supports creating templates and naming them.
    SessionContextstringNoSession context of up to 1,000 characters, which is used to pass through the user request information. If the procedure parameter is specified, the task flow status change callback API will return the value of this field.
    SubAppIdstringNoID of a subapplication in VOD. If you need to access a resource in a subapplication, enter the subapplication ID in this field; otherwise, leave it empty.
    VideoobjectNoRequest protocol parameter.
    MuxerstringNoRecording file format. Valid values: hls and mp4. If it is not set, it will be mp4 by default.
    EncryptKeystringNoHLS encryption public key. If it is not set, no encryption will be performed by default.
    AuthUrlstringNoDecryption private key address, which is required if the public key is set.

    Recording pause API

    This API is used to pause a running recording task.

    ParameterTypeRequiredDescription
    ActionstringYesRequested operation type. To pause recording, set it to Pause.
    DataobjectYesRequest protocol parameter.
    Data.TaskIDstringYesID of the recording task to be paused, which can be obtained in the response parameters of the recording start API.

    Recording resumption API

    This API is used to resume a paused recording task. The video content after resumption will be directly added to the content before pause without generating new video segments.

    ParameterTypeRequiredDescription
    ActionstringYesRequested operation type. To resume recording, set it to Resume.
    DataobjectYesRequest protocol parameter.
    Data.TaskIDstringYesID of the recording task to be resumed, which can be obtained in the response parameters of the recording start API.

    Recording page refresh API

    This API is used to initiate a request to refresh the page to be recorded.

    ParameterTypeRequiredDescription
    ActionstringYesRequested operation type. To refresh recording, set it to Refresh.
    DataobjectYesRequest protocol parameter.
    Data.TaskIDstringYesID of the recording task to be refreshed, which can be obtained in the response parameters of the recording start API.

    Recording stop API

    This API is used to initiate a recording stop request.

    ParameterTypeRequiredDescription
    ActionstringYesRequested operation type. To stop recording, set it to Stop.
    DataobjectYesRequest protocol parameter.
    Data.TaskIDstringYesID of the recording task to be stopped, which can be obtained in the response parameters of the recording start API.

    Recording task information query API

    This API is used to initiate a request to query the recording task information.

    ParameterTypeRequiredDescription
    ActionstringYesRequested operation type. To query a recording task, set it to Describe.
    DataobjectYesRequest protocol parameter.
    Data.TaskIDstringYesID of the recording task to be queried, which can be obtained in the response parameters of the recording start API.
    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