Alibaba Cloud ApsaraVideo VOD is an all-in-one solution that integrates audio and video management, processing, delivery, and playback. This topic guides you through integrating ApsaraVideo VOD from scratch to build a secure, cost-effective video playback solution for production environments.
Prerequisites
Log on to the ApsaraVideo VOD console and activate the service. You can select the pay-as-you-go or resource plan (subscription) billing method. For more information, see Billing overview.
ApsaraVideo VOD offers a free trial for new users to experience the service.
Region selection
ApsaraVideo VOD services are isolated by region. Choose a nearby service region to reduce network latency and improve data transfer speeds. Supported features also vary by region. For more information, see Service regions.
Solution setup
Step 1: Configure storage
Go to the Storage page in the ApsaraVideo VOD console. From the menu bar at the top, select the service region that you want to activate.

Click Enable VOD System Bucket and select a storage redundancy type. For higher availability, select zone-redundant storage.
Standard - Zone-redundant storage (ZRS)
This option uses a data redundancy mechanism to store copies of your data across multiple Availability Zones (AZs) within the same region. If one AZ becomes unavailable, your data remains accessible.
Standard - Locally redundant storage (LRS)
This option uses a data redundancy mechanism to store copies of your data on multiple devices in different facilities within a single Availability Zone (AZ). This ensures data durability and availability even if a hardware failure occurs.
Enabling the storage address may take some time. You can use the storage address only after its status changes to Normal.
Step 2: Upload audio and video files
Configure a transcoding template group before you upload audio and video files. This ensures that versions in multiple definitions are automatically generated after the video is uploaded. This optimizes the playback experience and saves bandwidth.
(Optional) Go to the Transcoding Template Groups page in the ApsaraVideo VOD console. Click Add Transcoding Template Group, set the required parameters, and save the configuration. For more information, see Video transcoding.

Select an upload method
Upload using an SDK (Recommended for production environments)
The backend service calls a software development kit (SDK) to obtain an upload credential. Then, the client, such as a web browser or an app, directly uploads the file to the ApsaraVideo VOD service. This is the most secure and efficient method.
NoteFor detailed code examples, see Overview of media upload.
python# Python example: The backend service obtains an upload credential and address. from aliyunsdkvod.request.v20170321 import CreateUploadVideoRequest from aliyunsdkcore.client import AcsClient import json # 1. Initialize the client. # Replace the placeholders with your AccessKey ID, AccessKey secret, and region ID. client = AcsClient('your-access-key-id', 'your-access-key-secret', 'cn-shanghai') # 2. Create an API request and set the parameters. request = CreateUploadVideoRequest.CreateUploadVideoRequest() request.set_Title('My Test Video') request.set_FileName('video_test.mp4') # request.set_TemplateGroupId('your-transcode-template-group-id') # Optional. Specify a transcoding template. # 3. Send the request and obtain the response. response = client.do_action_with_exception(request) response_data = json.loads(response) # 4. Return UploadAddress and UploadAuth to the client. upload_address = response_data['UploadAddress'] upload_auth = response_data['UploadAuth'] video_id = response_data['VideoId'] # After the client obtains the credential, use the upload SDK to upload the file.Upload using the console (Suitable for uploading or testing a small number of small files)
Go to the Media Library > Audio/Video page in the ApsaraVideo VOD console. Click Upload Audio/Video to go to the Upload Audio/Video page. Select local upload and add the files to upload.

Batch upload from URLs (Suitable for offline site migration when files are not stored locally and can be accessed over the internet). For more information, see Batch upload files from URLs.
Windows client (Suitable for batch uploading multiple large files). For more information, see Upload files using the Windows client.
Step 3: Configure an accelerated domain name (Optional)
If you play a media file using its playback URL, you are charged for outbound traffic from storage. To reduce costs, you can configure an accelerated domain name. The acceleration service fee is lower than the fee for outbound traffic from storage. For more information, see Add an accelerated domain name.
Step 4: Integrate playback
Obtain a playback credential (Recommended for production environments)
Backend API call
The backend service needs to call an API to dynamically generate a time-limited playback credential (PlayAuth) for each playback request.
python# Python example: Obtain a playback credential. from aliyunsdkvod.request.v20170321 import GetVideoPlayAuthRequest # The client has been initialized in the upload step. request = GetVideoPlayAuthRequest.GetVideoPlayAuthRequest() request.set_VideoId('your-video-id') # Replace the placeholder with the actual VideoId. request.set_AuthInfoTimeout(3000) # The validity period of the credential in seconds. In this example, the period is 50 minutes. response = client.do_action_with_exception(request) play_auth = json.loads(response)['PlayAuth'] # Return the obtained play_auth and video_id to the frontend.Frontend player integration
The frontend player uses the
vidandplayAuthobtained from the backend to initialize playback.Web
<!-- Web player example --> <div id="player-container"></div> <script src="https://g.alicdn.com/de/prismplayer/2.15.2/aliplayer-min.js"></script> <script> var player = new Aliplayer({ id: 'player-container', width: '100%', height: '500px', vid: 'your-video-id', // Obtained from the backend playauth: 'your-play-auth', // Obtained from the backend cover: 'https://your-domain.com/cover.jpg' // Thumbnail URL }, function (player) { console.log('The player is created.'); }); </script>Android
1. Create a player. AliPlayer player = AliPlayerFactory.createAliPlayer(context); // 2. Configure the playback source. VidAuth vidAuth = new VidAuth(); vidAuth.setVid("your-video-id"); vidAuth.setPlayAuth("your-play-auth"); vidAuth.setRegion("cn-shanghai"); // Set the region. // 3. Prepare for playback. player.setDataSource(vidAuth); player.prepare();iOS
1. Create a player. let player = AliPlayer() // 2. Configure the playback source. let vidAuth = AVPVidAuthSource() vidAuth.vid = "your-video-id" vidAuth.playAuth = "your-play-auth" vidAuth.region = "cn-shanghai" // Set the region. // 3. Prepare for playback. player.setSource(vidAuth) player.prepare()
URL signing
URL signing appends the signature information directly to the URL. This method is less secure than using playback credentials. It is suitable for scenarios where modifying the player is inconvenient. For more information, see URL signing.
Web player online experience
For testing and demonstration, you can also use the web player for an online experience.
Go to the Media Library > Audio/Video page in the ApsaraVideo VOD console. In the Actions column of the target video, click Manage.
Select the Video URL tab. In the Actions column of the target definition, click Copy URL.

Use the playback URL in the web player to play the video.
Extensions
Video transcoding: Set a transcoding template to automatically transcode videos upon upload and generate outputs in multiple definitions.
Workflow: Set up a workflow to automatically perform video processing tasks, such as transcoding, taking snapshots, and adding watermarks, after a video is uploaded.
Video editing: Perform professional video editing online or using an API or SDK.
Add an accelerated domain name: Configure an accelerated domain name to speed up video uploads and downloads and receive traffic discounts.
FAQ
How do I upload audio and video files in batches?
You can upload multiple audio and video files at a time using a PC client, batch uploading from URLs, or an upload SDK. For more information, see Overview of media upload.
How do I migrate audio and video files from OSS to ApsaraVideo VOD?
You can add your Object Storage Service (OSS) bucket to ApsaraVideo VOD if the following two conditions are met.
An OSS bucket of the Standard storage class exists in the destination region.
You have authorized ApsaraVideo VOD to access your OSS resources on the cloud resource access authorization page.
You can also prepare the source file addresses and use an upload tool for migration. For more information, see Overview of media upload.