All Products
Search
Document Center

Object Storage Service:How do I play online videos uploaded to OSS?

Last Updated:Nov 21, 2023

This topic describes how to play online videos that are uploaded to Object Storage Service (OSS) by using the OSS console, OSS SDKs, and stream ingest over Real-Time Messaging Protocol (RTMP).

Online playback methods

Play videos that are uploaded by using the OSS console or OSS SDKs

OSS uses public API operations to provide external-facing services. To play online videos that are upload to OSS by using the OSS console or OSS SDKs, you need to obtain the URLs of the video objects. For more information, see Share objects with signed URLs.

Play videos that are uploaded by using stream ingest over RTMP

The methods to play videos from the URLs of videos uploaded to OSS by using stream ingest over RTMP vary with the actual scenarios.

Live streaming

During stream ingest, you can use HTTP Live Streaming (HLS) to play the video content that is being uploaded:

  • On mobile platforms such as Android and iOS, enter the streaming URL of a LiveChannel in the browser. For more information, see ListLiveChannel.

  • On macOS, use Safari to play the content.

  • On other desktop platforms, use the VLC media player to play the content.

Playback on demand

During stream ingest, OSS uses live streaming to push or update M3U8 objects. In on-demand playback scenarios, you must call the PostVodPlaylist operation after stream ingest to assemble an M3U8 object for on-demand playback and use the object URL to play the uploaded video. For more information about the PostVodPlaylist operation, see PostVodPlaylist.

Note

In on-demand playback scenarios, you can set a larger group of pictures (GOP) size to reduce the number of transport stream (TS) objects and the bitrate.

FAQ

Why does object URL-based access from a browser trigger a download of the object instead of providing an object preview?

This happens by design for data transfer security if OSS is activated after 00:00 on October 9, 2022 and default domain names are used for access or transfer acceleration is enabled for a bucket after 11:07 on November 17, 2020 and the acceleration endpoint is used to request an object in the bucket. In the two cases, OSS returns two additional headers in the response:

x-oss-force-download: true
Content-Disposition: attachment

The Content-Disposition: attachment header triggers a download instead of a preview in a browser. To implement previews instead of downloads, map a custom domain name to the bucket that stores the requested object and use the custom domain to access the object. This prevents the preceding headers from being included in the response. For more information, see Map custom domain names.

Why does my browser fail to play videos that are uploaded to OSS?

Your browser may fail to play OSS videos for the following reasons:

  • Video format incompatibility: Your browser does not support the video format. For example, Safari supports the M3U8 format, but many other browsers do not. In this case, you can use ApsaraVideo Media Processing to convert the format of the video to a supported format. For more information, see Create a transcoding job.

  • MIME type detection failure: OSS sets the Multipurpose Internet Mail Extensions (MIME) type based on the object name extension by default. If a video object does not have an extension, you need to manually specify an MIME type. For more information, see How do I configure the Content-Type header?.

Can I have one URL for a download of an object and another URL for a preview of the object?

Yes, you can. To obtain a download URL and a preview URL of an object, perform the following steps:

  1. Map a custom domain name to the bucket that stores the object. For more information, see Map custom domain names.

  2. Use the custom domain name to generate a signed URL for the object and set the Content-Dispostion header to attachment and inline to generate a download URL and a preview URL for the object, respectively. For more information, see sign (generate signed object URLs).

How can I make an object permanently accessible by using its URL?

To make an object permanently accessible by using its URL, you can set the access control list (ACL) of the object to public-read-write. For more information, see Object ACLs.

Warning

All users can access the object over the Internet. This may result in unexpected access to the object and unexpectedly high fees. Exercise caution when you set the ACL to this value.

Do I need to register a domain name for my bucket?

If you want to map a custom domain name to a bucket, you need to register a domain name and resolve the domain name to the bucket. You can register a domain name with Alibaba Cloud Domains. For more information, see Register a domain name on Alibaba Cloud.

Do I need to complete Internet Content Provider (ICP) filing for the domain name mapped to my bucket?

If your bucket is in the Chinese mainland, you need to complete ICP filing for your domain name. You can use the ICP filing service of Alibaba Cloud to complete the ICP filing. For more information, see ICP filing application overview.

Why do I fail to access my bucket by using my custom domain name?

CNAME resolution takes time to take effect, and the time varies based on the TTL settings, DNS cache, and DNS propagation. In most cases, CNAME resolution takes effects within several minutes to several hours. If your bucket is inaccessible by using the mapped domain name, verify that all resolution settings are correct and allow some time for all DNS servers to receive the resolution update.

How do I configure hotlink protection?

You can configure the Referer list and specify whether to allow requests with empty Referer fields to control the sources of requests for videos in OSS. For more information, see Hotlink protection.

How do I access my bucket over HTTPS?

If you want to access your bucket by using your custom domain name over HTTPS, purchase and host the required digital certificates. For more information, see Host SSL certificates.

How do I process videos stored in OSS?

You can use ApsaraVideo Media Processing to edit, watermark, and transcode videos that are stored in OSS. For more information, see What is ApsaraVideo Media Processing?