You often need to download media files from ApsaraVideo VOD (VOD). These files can be audio, video, or images. Common use cases include media asset management, content delivery, and offline playback. This topic describes how to obtain download URLs and download files using the console, an API or SDK, or a mobile SDK. The methods are fast, secure, and cost-effective.
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 provides a straightforward way to download files. This method is ideal for downloading a small number of files or for business testing.
Log on to the ApsaraVideo VOD console.
In the left navigation pane, choose Media Files > Audio/Video to go to the Audio/Video list page.
Find the target file and click Manage in the Actions column. Select the Video URL or Audio URL tab. In the Actions column for the desired definition, click Copy.
Paste the copied URL into a browser or download tool to start the download.
Download multiple files
The console provides a batch export feature for media asset information when you need to download multiple files.
Log on to the ApsaraVideo VOD console.
In the left navigation pane, choose Media Files. Based on the file type, select Audio/Video or Image to go to the list page.
On the list page, use the filter or search feature to locate and select the media files that you want to export.
Click the
icon in the upper-right corner of the page 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
APIs provide a flexible way to obtain download URLs for various media resources, such as source files, transcoded files, and thumbnails. The following table lists the APIs for obtaining download URLs for different media files.
Media asset type | Retrieve the 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 |
| You can search for information about multiple media types at once. The response includes all the URL types mentioned above. |
Use a server-side SDK to call APIs to retrieve and update media asset information. For more information, see VOD SDK usage guide.
Perform the download operation
You can integrate the download feature into your application using APIs to automate the process. The following code provides a Python SDK example. For more SDK examples, see the OpenAPI Portal.
Prepare the environment.
Install the VOD Python SDK.
pip install aliyun-python-sdk-vodObtain 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 client SDK
For mobile application scenarios, ApsaraVideo VOD supports caching videos locally for offline viewing. Offline download is available in two modes: standard download and secure download.
Standard download: The downloaded video file is not encrypted and can be copied and played by any player. This mode is suitable for public content or scenarios with low copyright requirements.
Secure download: The downloaded video file is encrypted. It can only be decrypted and played by an ApsaraVideo Player SDK that is integrated with the same key. This mode is suitable for copyright-sensitive scenarios, such as paid courses and exclusive content.
Steps
Configure the download mode.
Log on to the ApsaraVideo VOD console. Go to Configuration Management > CDN Configuration > Download Settings.
Select standard download or secure download as needed. If you select secure download, you must 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. For more information, see Integrate the Android SDK and Integrate the iOS SDK.
Complete the video download.
Integrate the video download module into your Android or iOS project. For more information, see Video download for Android and Video download for iOS.
Billing
Media file download URLs fall into the following two categories:
Storage address
If you do not configure an accelerated domain name, the system uses the media asset storage address directly and incurs outbound traffic fees.
Accelerated address:
When you configure an accelerated domain name, you can achieve faster access speeds. The download URL becomes an accelerated URL, and you will incur fees for the acceleration service.
If you configure blacklists and whitelists, you are subject to restrictions such as Referer hotlink protection and IP blacklist policies, which align with online playback rules.
FAQ
Why can't I play the downloaded video?
If video encryption, such as HLS encryption, is enabled for the transcoded output file, the downloaded file remains encrypted. You must use the ApsaraVideo Player SDK to decrypt and play it. For more information, see Video encryption.
How do I download many media files?
Retrieve media file information with paging using SearchMedia - Search Media Information, and then follow Scenario 2: Download via API to download.