Download audio, video, and image files from VOD for media asset management, content delivery, or offline playback. Obtain download URLs through the console, API/SDK, or mobile player SDK.
Scenarios
-
Download from the console: Suitable for quick validation or temporary export of a small number of files.
-
Download using an API: Suitable for automated batch processing of files.
-
Download offline using a player SDK: Suitable for custom application scenarios.
Scenario 1: Download from the console
Download a single file
The console is ideal for downloading a few files for quick validation or testing.
-
Log on to the ApsaraVideo VOD console.
-
In the left navigation pane, choose Media Files > Audio/Video.
-
Find the target file, click Manage in the Actions column, select the Video URL or Audio URL tab, then click Copy for the desired definition.
-
Paste the copied URL into a browser or download tool to start the download.
Download multiple files
Use the batch export feature to export media asset information for multiple files.
-
Log on to the ApsaraVideo VOD console.
-
In the left navigation pane, choose Media Files, then select Audio/Video or Image.
-
Use the filter or search feature to locate and select the files to export.
-
Click the
icon in the upper-right corner to export the media asset information. -
Paste the URLs for the media assets into a browser or download tool to start the download.
Scenario 2: Download using an API
Obtain download URLs
Use the following APIs to obtain download URLs for source files, transcoded files, and thumbnails.
|
Media asset type |
API |
Address field |
Description |
|
Source file |
|
The original audio or video file that was uploaded. |
|
|
Transcoded file |
|
The URL of the transcoded stream. |
|
|
Video thumbnail |
|
The thumbnail image of the video. |
|
|
Video snapshot |
|
An array of snapshot URLs for the video. |
|
|
Image file |
|
The URL of the image. |
Obtain download URLs in batches
|
Address Type |
Obtain API |
Address field |
Description |
|
Batch search |
|
Searches across multiple media types. Returns all URL types listed above. |
Use a server-side SDK to call APIs to retrieve and update media asset information. VOD SDK usage guide.
Perform the download operation
The following Python SDK example automates the download. Additional examples are available in the OpenAPI Portal.
-
Prepare the environment.
Install the VOD Python SDK.
pip install aliyun-python-sdk-vod -
Obtain the download URL.
Call the GetMezzanineInfo operation to retrieve the source file information.
import json from aliyunsdkcore.client import AcsClient from aliyunsdkvod.request.v20170321 import GetMezzanineInfoRequest # Initialize the client # Replace with your AccessKey ID, AccessKey secret, and region ID client = AcsClient('YOUR_ACCESS_KEY_ID', 'YOUR_ACCESS_KEY_SECRET', 'cn-shanghai') # 1. Create a request request = GetMezzanineInfoRequest() request.set_accept_format('json') request.set_VideoId("YOUR_VIDEO_ID") # Replace with your video ID request.set_OutputType("oss") # Recommended: Returns the OSS storage address for lower cost request.set_AuthTimeout(3600) # Set the URL validity period to 1 hour (3600 seconds) # 2. Send the request and get the response response = client.do_action_with_exception(request) result = json.loads(response) # 3. Parse the download URL download_url = result['Mezzanine']['FileURL'] print(f"Source file download URL: {download_url}") # (Optional) Use the requests library to download the file import requests print("Starting file download...") file_response = requests.get(download_url, stream=True) if file_response.status_code == 200: with open('downloaded_video.mp4', 'wb') as f: for chunk in file_response.iter_content(chunk_size=8192): f.write(chunk) print("File downloaded successfully: downloaded_video.mp4") else: print(f"Download failed, status code: {file_response.status_code}") print(f"Error message: {file_response.text}")
Scenario 3: Download offline using a player SDK
VOD supports caching videos locally on mobile devices for offline viewing in two modes: standard download and secure download.
-
Standard download: The video is not encrypted and can be copied and played by any player. Suitable for public content or low-copyright scenarios.
-
Secure download: The video is encrypted and can only be played by an ApsaraVideo Player SDK integrated with the matching key. Suitable for paid courses and copyright-sensitive content.
Steps
-
Configure the download mode.
-
Log on to the ApsaraVideo VOD console. Go to Configuration Management > CDN Configuration > Download Settings.
-
Select standard or secure download. For secure download, generate and securely store the encryption key on this page.
-
-
Integrate the player SDK.
Integrate the ApsaraVideo Player SDK into your Android or iOS project: Integrate the Android SDK, Integrate the iOS SDK.
-
Complete the video download.
Integrate the video download module into your Android or iOS project: Video download for Android, Video download for iOS.
Billing
Download URLs fall into two categories:
-
Storage address
-
Without an accelerated domain name, downloads use the storage address directly and incur outbound traffic fees.
-
-
Accelerated address:
-
If you configure an accelerated domain name, download URLs become accelerated URLs, providing faster downloads and incurring acceleration service fees.
-
If you configure blacklists and whitelists, restrictions such as Referer hotlink protection and IP blacklists apply, consistent with online playback rules.
-
FAQ
Why can't I play the downloaded video?
If the transcoded output uses encryption (such as HLS encryption), the downloaded file remains encrypted. Use the ApsaraVideo Player SDK to decrypt and play it. Video encryption.
How do I download many media files?
Use SearchMedia - Search Media Information with paging to retrieve file URLs, then follow Scenario 2: Download via API to download.