Bu sayfa henüz yerel dilinizde mevcut değildir. Daha fazla dil seçeneği eklemek için yoğun bir şekilde çalışıyoruz. Desteğiniz için teşekkür ederiz.

Compute
Elastic Cloud Server
Huawei Cloud Flexus
Bare Metal Server
Auto Scaling
Image Management Service
Dedicated Host
FunctionGraph
Cloud Phone Host
Huawei Cloud EulerOS
Networking
Virtual Private Cloud
Elastic IP
Elastic Load Balance
NAT Gateway
Direct Connect
Virtual Private Network
VPC Endpoint
Cloud Connect
Enterprise Router
Enterprise Switch
Global Accelerator
Management & Governance
Cloud Eye
Identity and Access Management
Cloud Trace Service
Resource Formation Service
Tag Management Service
Log Tank Service
Config
OneAccess
Resource Access Manager
Simple Message Notification
Application Performance Management
Application Operations Management
Organizations
Optimization Advisor
IAM Identity Center
Cloud Operations Center
Resource Governance Center
Migration
Server Migration Service
Object Storage Migration Service
Cloud Data Migration
Migration Center
Cloud Ecosystem
KooGallery
Partner Center
User Support
My Account
Billing Center
Cost Center
Resource Center
Enterprise Management
Service Tickets
HUAWEI CLOUD (International) FAQs
ICP Filing
Support Plans
My Credentials
Customer Operation Capabilities
Partner Support Plans
Professional Services
Analytics
MapReduce Service
Data Lake Insight
CloudTable Service
Cloud Search Service
Data Lake Visualization
Data Ingestion Service
GaussDB(DWS)
DataArts Studio
Data Lake Factory
DataArts Lake Formation
IoT
IoT Device Access
Others
Product Pricing Details
System Permissions
Console Quick Start
Common FAQs
Instructions for Associating with a HUAWEI CLOUD Partner
Message Center
Security & Compliance
Security Technologies and Applications
Web Application Firewall
Host Security Service
Cloud Firewall
SecMaster
Anti-DDoS Service
Data Encryption Workshop
Database Security Service
Cloud Bastion Host
Data Security Center
Cloud Certificate Manager
Edge Security
Blockchain
Blockchain Service
Web3 Node Engine Service
Media Services
Media Processing Center
Video On Demand
Live
SparkRTC
MetaStudio
Storage
Object Storage Service
Elastic Volume Service
Cloud Backup and Recovery
Storage Disaster Recovery Service
Scalable File Service Turbo
Scalable File Service
Volume Backup Service
Cloud Server Backup Service
Data Express Service
Dedicated Distributed Storage Service
Containers
Cloud Container Engine
SoftWare Repository for Container
Application Service Mesh
Ubiquitous Cloud Native Service
Cloud Container Instance
Databases
Relational Database Service
Document Database Service
Data Admin Service
Data Replication Service
GeminiDB
GaussDB
Distributed Database Middleware
Database and Application Migration UGO
TaurusDB
Middleware
Distributed Cache Service
API Gateway
Distributed Message Service for Kafka
Distributed Message Service for RabbitMQ
Distributed Message Service for RocketMQ
Cloud Service Engine
Multi-Site High Availability Service
EventGrid
Dedicated Cloud
Dedicated Computing Cluster
Business Applications
Workspace
ROMA Connect
Message & SMS
Domain Name Service
Edge Data Center Management
Meeting
AI
Face Recognition Service
Graph Engine Service
Content Moderation
Image Recognition
Optical Character Recognition
ModelArts
ImageSearch
Conversational Bot Service
Speech Interaction Service
Huawei HiLens
Video Intelligent Analysis Service
Developer Tools
SDK Developer Guide
API Request Signing Guide
Terraform
Koo Command Line Interface
Content Delivery & Edge Computing
Content Delivery Network
Intelligent EdgeFabric
CloudPond
Intelligent EdgeCloud
Solutions
SAP Cloud
High Performance Computing
Developer Services
ServiceStage
CodeArts
CodeArts PerfTest
CodeArts Req
CodeArts Pipeline
CodeArts Build
CodeArts Deploy
CodeArts Artifact
CodeArts TestPlan
CodeArts Check
CodeArts Repo
Cloud Application Engine
MacroVerse aPaaS
KooMessage
KooPhone
KooDrive
Help Center/ SparkRTC/ API Reference/ Examples/ Example 2: Creating a Mixed Stream Recording Job

Example 2: Creating a Mixed Stream Recording Job

Updated on 2025-02-08 GMT+08:00

Scenarios

Example 1: Creating a Single Stream Recording Job describes how to record audio and video streams of each user in a room and save them into independent files. This section describes how to record multiple streams of users in a room and save them into one file by calling the SparkRTC APIs.

Prerequisites

  • You have obtained the SparkRTC endpoint rtc-api.myhuaweicloud.com.
  • You have created an OBS bucket for storing recording files and authorized SparkRTC to access the OBS bucket.

Procedure

  1. Obtain a user token for authenticating the calling of SparkRTC APIs.

    Obtain username, password, and domainname in My Credentials and call the following API to obtain the token. For details, see Making an API Request.
    POST https://iam.myhuaweicloud.com/v3/auth/tokens
    Content-Type: application/json
    {
      "auth": {
        "identity": {
          "methods": [
            "password"
          ],
          "password": {
            "user": {
              "name": "username", //Username
              "password": "password", //Login password
              "domain": {
                "name": "domainname" //Name of the account to which the user belongs
              }
            }
          }
        },
        "scope": {
          "domain": {
             "name": "domainname"  //Name of the account to which the user belongs
          }
        }
      }
    }
    Information in the red box in Figure 1 indicates the obtained user token.
    Figure 1 Obtaining a user token

  2. Call the API for creating a SparkRTC application.

    1. Select the POST request method and enter the URI.
      https://rtc-api.myhuaweicloud.com/v2/apps
    2. In the request header, add X-Auth-Token and set its value to the token obtained in 1.
    3. Specify the following parameter in the request body:
      {
        "app_name" : "rtctest"
      }
    4. If the request is successful, the ID of the created application is returned.
      {
      	"app_id": "5ff9701f2346968bb306cb43",
      }

  3. Call the API for creating or updating a recording template to create a recording template.

    1. Select the POST request method and enter the URI.
      https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/record-rules
    2. In the request header, add X-Auth-Token and set its value to the token obtained in 1.
    3. Specify the following parameters in the request body:
      {
      	"obs_addr": {
      		"bucket": "obsName",
      		"location": "cn-north-4",
      		"object": "Record/",
      		"project_id": "01234567890123456789012345678901"
      	},
      	"record_formats": ["MP4"],
      	"mp4_config": {}
      }
    4. If the request is successful, the created recording template is returned.
      {
      	"app_id": "5ff9701f2346968bb306cb43",
      	"rule_id": "5d0ec2c53a2c15625017adb8bbbcd9ab",
      	"create_time": "2021-04-21T10:29:33Z",
      	"hls_config": {
      		"record_cycle": 0,
      		"record_max_duration_to_merge_file": 0
      	},
      	"mp4_config": {
      		"record_cycle": 7200,
      		"record_max_duration_to_merge_file": 0,
      		"record_prefix": "Record/{publish_domain}/{app}/{record_type}/{record_format}/{stream}_{file_start_time}/{stream}_{file_start_time}"
      	},
      	"obs_addr": {
      		"bucket": "obsName",
      		"location": "cn-north-4",
      		"object": "Record/",
      		"project_id": "01234567890123456789012345678901"
      	},
      	"record_formats": [
      		"MP4"
      	],
      	"update_time": "2021-04-21T10:29:33Z"
      }

  4. Call the API for configuring a SparkRTC recording event callback.

    1. Select the PUT request method and enter the URI.
      https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/record-callback
    2. In the request header, add X-Auth-Token and set its value to the token obtained in 1.
    3. Specify the following parameters in the request body:
      {
      	"url": "http://mydomain.com/callback",
      	"auth_key": "8923ab8c2dcef4538923ab8c2dcef453"
      }
    4. If the request is successful, information about the created callback is returned.
      {
      	"app_id": "5ff9701f2346968bb306cb43",
      	"record_callback": {
      		"auth_key": "8923ab8c2dcef4538923ab8c2dcef453",
      		"update_time": "2021-04-07T12:05:18.0718Z",
      		"url": "http://mydomain.com/callback",
      		"notify_event_subscription": [
      			"RECORD_NEW_FILE_START",
      			"RECORD_FILE_COMPLETE",
      			"CLOUD_RECORD_OVER"
      		]
      	}
      }

  5. An end user joins a SparkRTC room using the SparkRTC app. For details about the integration development of the SparkRTC app, see Client SDK.
  6. Call the API for starting a mixed stream recording job to create a recording job.

    1. Select the POST request method and enter the URI.
      https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/mix-stream-jobs
    2. In the request header, add X-Auth-Token and set its value to the token obtained in 1.
    3. Specify the following parameters in the request body:
      {
      	"mix_param": {
      		"room_id": "room001",
      		"encode_template": "1920x1080_30_4620",
      		"max_idle_time": 30,
      		"layout_template": "nine_grids_view" //If the video layout is in screen sharing mode, set this parameter to screen_share_left or screen_share_right.
      	},
      	"record_param": {
      		"record_rule_id": "5d0ec2c53a2c15625017adb8bbbcd9ab"
      	}
      }

      layout_template: video layout template.

      • nine_grids_view: adaptive gallery view template.

        Images of each user are tiled and have the same size. The size and position of each image are dynamically adjusted based on the number of users. A maximum of 25 images are supported. The following figure shows the layouts with different numbers of users.

        • If the aspect ratio of the actual video stream is different from that of the screen, a video image will be cropped to adapt to the screen size.
        • If a user exits the room, the image of this user will be replaced by the next user who enters the room.
        • If there are not enough users in the room, the rest of the screen displays a background color.
        • A user who only sends audio still occupies a screen.
        • A background image is supported. If there are not enough users in the room, the rest of the screen displays a background image.
      • screen_share_left and screen_share_right: adaptive screen sharing templates with the main screen on the left or right.

        A shared screen or a presenter view is displayed in the main screen on the right or left. Other users are arranged vertically on the side of the main screen. A maximum of 17 screens are supported. The following figures show the layouts with different numbers of users.

        • The main screen displays a presenter view or a shared screen.
        • The main screen displays the video of a specific user. If no user is specified or the specified user does not enter the room, the main screen displays the background color.
        • Images in the main screen on the left are zoomed in or out to display the complete content. Images in the small screens on the right are cropped to adapt to the screen size.
        • The small screens of users on the right are sorted by the time when they enter the room.
        • If a user in the right small screen exits the room, the image of this user will be replaced by the next user who enters the room.
        • If there are not enough users in the room, the rest of the screen displays a background color.
        • A user who only sends audio still occupies a screen.
        • A background image is supported. If there are not enough users in the room, the rest of the screen displays a background image.
    4. If the request is successful, information about the mixed stream recording job is returned.
      {
      	"app_id": "5ff9701f2346968bb306cb43",
      	"create_time": "2021-04-21T11:47:32Z",
      	"job_id": "607f9fc100d861eeefff9b300b388dab",
      	"job_unique_id": "87b1f2b8da9c44cd",
      	"mix_param": {
      		"room_id": "room001",
      		"layout_template": "nine_grids_view",
      		"encode_template": "1920x1080_30_4620",
      		"max_idle_time": 30
      	},
      	"push_param": {
      		"rtmp_urls": null
      	},
      	"record_param": {
      		"record_rule_id": "5d0ec2c53a2c15625017adb8bbbcd9ab"
      	},
      	"room_id": "room001",
      	"start_time": "2021-04-21T11:47:32Z",
      	"state": "INIT",
      	"stop_time": "0001-01-01T00:00:00Z",
      	"stream_name": "m_607f9fc100d861eeefff9b300b388dab_room001",
      	"update_time": "2021-04-21T11:47:32Z"
      }

  7. After the audio or video interaction is complete in the SparkRTC room, obtain the recording files from the configured OBS bucket.

Sitemizi ve deneyiminizi iyileştirmek için çerezleri kullanırız. Sitemizde tarama yapmaya devam ederek çerez politikamızı kabul etmiş olursunuz. Daha fazla bilgi edinin

Feedback

Feedback

Feedback

0/500

Selected Content

Submit selected content with the feedback