All Products
Search
Document Center

Intelligent Media Management:Use Alibaba Cloud CDN together with live transcoding to accelerate video playback

Last Updated:Jan 17, 2025

If you configure a private Object Storage Service (OSS) bucket as your origin server to implement access authentication and block unauthorized access, we recommend that you grant Alibaba Cloud CDN permissions to access the OSS bucket and enable the private bucket access feature. This way, Alibaba Cloud CDN Edge Security Acceleration (ESA) can accelerate the delivery of resources in the private OSS bucket. You can use the live transcoding feature to play videos uploaded to OSS on different terminals and under different network conditions. To improve the video playback and transcoding speeds and efficiency, you can use Alibaba Cloud CDN, which helps reduce bandwidth consumption and loads in OSS.

Scenarios

You can use Alibaba Cloud CDN to accelerate delivery of frequently accessed videos. This approach reduces the load on original video storage services, such as OSS, optimizes bandwidth costs, and ensures a fast and seamless viewing experience for your audience.

Prerequisites

Procedure

Step 1: Authorize Alibaba Cloud CDN to access the private OSS bucket and IMM

When you configure back-to-origin routing to a private bucket, you are prompted to authorize Alibaba Cloud CDN to access OSS by using the automatically created AliyunCDNAccessingPrivateOSSRole role. You need to modify the policy for the AliyunCDNAccessingPrivateOSSRole role in the Resource Access Management (RAM) console to also allow Alibaba Cloud CDN to access IMM.

The following examples show how to grant full access permissions and fine-grained access permissions.

  1. Grant the AliyunCDNAccessingPrivateOSSRole role full access permissions on IMM and OSS.

    lQLPJwnayVIjBu3NAprNBRmw47a43DIWzK0GDrqrts9NAA_1305_666

  1. Grant AliyunCDNAccessingPrivateOSSRole fine-grained access permissions. For more information, see Permissions. The following example shows a custom policy named aliplayer-test that grants the least permissions that are required in this scenario.

    lQLPJw1pMNpkgI3NAlDNBQ6wmmdn6k_aL5YGDroSiPggAA_1294_592

{
    "Statement": [
        {
            "Effect": "Allow",
            "Action": [
                "oss:GetObject",
                "oss:PostProcessTask",
                "oss:ProcessImm"
            ],
            "Resource": "*"
        },
        {
            "Action": [
                "imm:GenerateVideoPlaylist",
                "imm:LiveTranscoding"
            ],
            "Resource": "*",
            "Effect": "Allow"
        },
        {
            "Effect": "Allow",
            "Action": "ram:PassRole",
            "Resource": "acs:ram:*:*:role/aliyunimmdefaultrole"
        }
    ],
    "Version": "1"
}

Step 2: Configure back-to-origin rules for live transcoding

  1. Log on to the Alibaba Cloud CDN console.

  2. In the left-side navigation pane, click Domain Names.

  3. On the Domain Names page, find the domain name and click Manage.

  4. In the left-side navigation tree, click Rules Engine.

  5. On the Rules Engine page, click Add Rule to add an extension-based rule that includes TS files.

    image

    Note

    If the bucket contains TS files that are not generated from a live transcoding process, you must also add a rule that excludes such TS files.

  6. In the left-side tree, click Origin Fetch. Click the Parameter Rewrite tab, turn on the Feature Switch toggle. In the Parameter Rewrite dialog box, enter x-oss-process=if_status_eq_404{hls/ts} in the Add field and select the rule that you created earlier from the Rule Condition drop-down list.

    image

Use Alibaba Cloud CDN to access video data in the bucket to trigger live transcoding

You added the x-oss-process=if_status_eq_404{hls/ts} parameter during back-to-origin configuration. You can directly use the CDN-accelerated domain name and the file path to M3U8 files in the bucket to trigger live transcoding, without the need to add the hls/sign parameter. For more information, see Live transcoding.

Important

You must use a browser or player that supports HTTP Live Streaming (HLS). For example, you can use the VLC player.