This topic provides answers to some commonly asked questions about ApsaraVideo Player SDK.
Which protocol should I use for standard streaming, RTMP or HTTP-FLV?
We recommend that you use the HTTP Flash Video (HTTP-FLV) protocol for live streaming.
Real-Time Messaging Protocol (RTMP) and HTTP-FLV URLs for live streaming are generated in the ApsaraVideo VOD console at the same time. The URLs contain the same data but use different network protocols.
HTTP is the primary protocol for transmission of information across the Internet. Connections over the HTTP protocol, such as connections among Alibaba Cloud CDN, Internet service providers (ISPs), and intermediary devices, are highly optimized. The default port for the HTTP protocol is 80 and the default port for the HTTPS protocol is 443. In most cases, the ports are added to the whitelist and cannot be disabled. RTMP is an outdated protocol and uses 1935 as the default port. Port 1935 may be disabled by the firewall. This may cause errors. Compared with RTMP, HTTP-FLV is more stable and provides better performance. For example, video playback over HTTP-FLV has a lower stuttering rate and lower latency than RTMP.
Playback failures
How do I troubleshoot playback failures?
Video playback failures may be caused by errors such as stream encoding errors, server or network errors, Alibaba Cloud CDN errors, format errors, and bucket errors. The following section describes the possible errors and corresponding solutions:
Overdue payment errors: Check your account balance. If overdue payments exist within your Alibaba Cloud account, videos cannot be played.
Server or network errors: The
4400
error code is returned when your video failed to be played. The4400
error code indicates that the resources cannot be loaded due to server or network errors. Check whether the SSL certificate is configured and whether your SSL certificate is valid.Format errors: The video format is incompatible with ApsaraVideo Player. For more information about the playback formats supported by ApsaraVideo VOD, see Features.
NoteTo play M3U8 videos, you must use a custom domain name. For more information about how to add domain names, see Add a domain name for CDN.
Bucket errors: The specified bucket is invalid or the authentication information of a private bucket has expired. You can disable bucket authentication and set the access control list (ACL) of the bucket to public-read.
Cross-region errors: Check whether the region of the accelerated domain name and the region in which the video is being played are the same. If the regions are different, video playback fails. In this case, you can add a new domain name to accelerate or change the region of the existing accelerated domain name.
What do I do if videos can be played in ApsaraVideo VOD but fail to be played on other platforms?
Perform the following steps to troubleshoot the error:
Check whether the video still exists in ApsaraVideo VOD.
Check whether an accelerated domain name is added.
If no accelerated domain name is added, check whether the ACL of the bucket is private. If the ACL of the bucket is private, disable authentication and set the ACL to public-read. This operation may introduce risks to your bucket.
If an accelerated domain name is added, check whether authentication is enabled. If authentication is enabled, configure a longer validity period for the signed URL or disable authentication. Disabling authentication can expose your resources to risks.
What do I do if videos uploaded to ApsaraVideo VOD can be played on all devices except iOS devices?
Cause: The compatibility of Safari on iOS devices is limited. If a video is highly compressed or the encoding profile of the video is high, the video may fail to be played in Safari.
Solution: We recommend that you transcode the video before you play it. For more information, see Audio and video transcoding.
Long startup duration
If the startup duration is long when you play an MP4 video, the playback error may be caused by the format of the video file. To accelerate data parsing, you must place the moov atom before the mdat atom. The mdat atom contains the media data and the moov atom acts as the index of media data. You can transcode the media file to move the moov atom ahead of the mdat atom.
For more information, see Recommended output formats and transcoding tools.
To check the location of the moov atom, run the following command:
// The video source address can be the path of a local file or the URL of an online video. Example: http://pla****.alicdn.com/video/aliyunmedia.mp4. ffmpeg -v trace -i "Video source address" 2>&1 | grep -e type:\'mdat\' -e type:\'moov\'
In the following image, the moov atom is placed ahead of the mdat atom. In this case, the video can be played as expected.
In the following image, the mdat atom is placed ahead of the moov atom. In this case, playback errors may occur.
ApsaraVideo VOD provides playback solutions for ApsaraVideo Player SDKs for Android and iOS that reduce the startup duration to milliseconds. For more information, see Use ApsaraVideo Player to perform instant loading in full screen mode.
Playback of encrypted videos
What do I do if DRM-encrypted videos cannot be played by ApsaraVideo Player for Web?
You can use ApsaraVideo Player for Web to play videos that are encrypted by using Digital rights management (DRM) only on specific browsers. For more information about the supported browsers, see Features of the HTML5 player supported by browsers.
What is MtsHlsUriToken used for when I play HLS-encrypted videos? How do I obtain MtsHlsUriToken?
MtsHlsUriToken is a user-defined parameter. In HLS encryption, an encryption string is written to the HLS stream and the URL of the decryption server is added to the M3U8 index file. If you want to limit access to the encrypted video, you can use MtsHlsUriToken for identity verification before the video is decrypted for playback.
When you configure encryption, you must set up a token issuance service to generate MtsHlsUriToken. For more information, see Step 4 in the Encrytion procedure section of the HLS encryption topic.
Cross-region playback
What do I do if videos uploaded to OSS in the UK (London) region take a long time to load from the Chinese mainland?
Access from regions in the Chinese mainland to UK (London) is cross-region access. We recommend that you activate Global Accelerator (GA) and add a domain name to accelerate video loading.
What do I do if videos take a long time to load and video stuttering frequently occurs when I access ApsaraVideo VOD from regions outside the Chinese mainland?
In most cases, stuttering occurs when the network connection is unstable. If video stuttering continues for an extended period of time and causes an error to be reported in ApsaraVideo Player, the connection to CDN may be interrupted. If video stuttering frequently occurs, check whether your network speed matches the video bitrate. If your network speed does not match the video bitrate, increase your network speed or reduce the video bitrate.
Playback of videos stored in OSS
What do I do if a large number of requests are sent when I play a video stored in OSS?
Check whether the source video is abnormal. For example, check whether a large number of requests are sent when the player decrypts the source video. We recommend that you use an ApsaraVideo VOD transcoding template to transcode the source video for playback. For more information, see Audio and video transcoding.
How do I configure to preview the image when I click the URL of an image that is uploaded to ApsaraVideo VOD?
You can preview images stored in ApsaraVideo VOD only by using custom domain names. If you use the default domain name to access an image, the image is forcibly downloaded. You can add your custom domain name to ApsaraVideo VOD. For more information, see Add a domain name for CDN.
SSL certificates
What do I do if videos cannot be played on specific PCs and the 4400
error code is returned?
The 4400
error code indicates that the resources cannot be loaded due to server or network errors, or that the video format is not supported. Check whether an SSL certificate is configured.
Playback URLs
How do I generate a short playback URL for a video stored in ApsaraVideo VOD?
If the ACL of the bucket in which the video is stored is private, the video playback URL contains authentication information and the URL is long. If the ACL of the bucket is public-read or public-read-write, no authentication information is added to the playback URL and the URL is short. For more information about the read and write permissions on the storage bucket and how to change the permissions, see Manage storage buckets.
If the ACL of the bucket is public-read or public-read-write, the bucket is exposed to risks of hotlinking and illegal downloads. We recommend that you set the ACL of your bucket to private.
Why does a non-transcoded video fail to be played after I set the transcoding format to HLS?
You can use video IDs and playback credentials to play only the transcoded videos in ApsaraVideo Player. Videos that are not transcoded can only be played by using playback URLs. You can call the GetMezzanineInfo operation to obtain the source video URL or log on to the ApsaraVideo VOD console to view the video playback URL.
Does a video stored in ApsaraVideo VOD have multiple playback URLs?
If the ACL of the bucket in which the video is stored is private, the playback URL of the video has an expiration time. The authentication string included in the auth_key
parameter in the playback URL varies based on the expiration time that you specify.
If you need a permanent playback URL for a video, you must change the ACL of the bucket in which the video is stored to public-read or public-read-write. Then, a playback URL is generated. The content before ?
is the permanent playback URL. For more information about the read and write permissions on the storage bucket and how to change the permissions, see Manage storage buckets.
If the ACL of the bucket is public-read or public-read-write, the bucket is exposed to risks of hotlinking and illegal downloads. We recommend that you set the ACL of your bucket to private.
Why a video uploaded to ApsaraVideo VOD can only be played in browsers after I access the playback URL of the video from platforms such as Taobao?
Video playback depends on browsers and the transcoding capabilities of your local device. In most cases, you are redirected to a browser to play videos.
Why am I unable to play the new video after I upload the updated video?
After you update the video, you must refresh the playback URL to obtain the latest video data. For more information about how to refresh the URL by using the ApsaraVideo VOD console, see Refresh and prefetch. For more information about how to refresh the URL by using the ApsaraVideo VOD API or SDK, see PreloadVodObjectCaches or RefreshMediaPlayUrls.
How do I obtain the pixels of each video frame in ApsaraVideo Player?
ApsaraVideo Player for Android: listen for the
OnRenderFrameCallback
event.ApsaraVideo Player for iOS: listen for the
onRenderingFrame
event.player.renderingDelegate = self; #pragma mark CicadaRenderingDelegate - (BOOL)onRenderingFrame:(CicadaFrameInfo*) frameInfo{ if(frameInfo.frameType==Cicada_FrameType_Video){ // Obtain the pixels of video frames. NSLog(@"receive HW frame:%p pts:%ld foramt %d", frameInfo.video_pixelBuffer, frameInfo.pts, CVPixelBufferGetPixelFormatType(frameInfo.video_pixelBuffer)); } else if (frameInfo.frameType==Cicada_FrameType_Audio){ // This feature is not supported for audio. } return NO; }
ApsaraVideo Player for Web: You cannot obtain the pixels of video frames.
Why am I unable to obtain playback URLs of AVI videos uploaded to ApsaraVideo VOD by using the API or SDK?
You cannot obtain AVI videos by calling the GetPlayInfo operation. Therefore, you cannot use SDKs that use this operation to obtain playback URLs of AVI videos.
You can view the playback URL of an AVI video in the ApsaraVideo VOD console. For more information, see Query audio/video files.
Playback stuttering
What do I do to reduce video stuttering and improve the cache hit ratio?
You can configure the following settings: URL signing, refresh and prefetch, cache TTL, and parameter filtering.
What do I do if video stuttering occurs when I drag the progress handle to the middle of the progress bar?
When you drag the progress handle on the progress bar, ApsaraVideo Player loads the keyframes before and after the position to which you seek to display the required video image. Stuttering occurs in a video when the keyframes are insufficient and the required video image takes more time to be displayed. In this case, we recommend that you transcode the video to add more keyframes to the video. For more information about transcoding, see Audio and video transcoding.
Video thumbnails
Why am I unable to obtain video thumbnails?
By default, the ApsaraVideo VOD console uses the HTTPS protocol. The screenshots can be displayed and previewed only if HTTPS is used. You can also open the browser developer tool to view error details.
Video review
Why am I unable to play videos submitted for manual review?
ApsaraVideo VOD provides two review modes: Review After Publish and Review Before Publish. If you use the latter, you can play the video only after the video passes the review. The following items describe the differences between the two review modes:
Review After Publish: After a video is transcoded, the video is marked as Normal and can be played. You need to perform a manual review on the video in the Content Moderation module. If you block the video, the video cannot be played.
Review Before Publish: After a video is transcoded, the video is marked as Reviewing and cannot be played. You can play the video only after the video passes the review.
Parameter parsing
What is a video ID? Why is a video ID required? How do I obtain a video ID?
After you upload a video file, ApsaraVideo VOD provides you with a video ID instead of a video URL to ensure the security of the video file. You can obtain the video URL by calling an API operation in ApsaraVideo VOD. For more information, see GetPlayInfo.
After you upload a video to ApsaraVideo VOD, you can obtain the video ID.
You can also obtain a video ID by using the ApsaraVideo VOD console. Perform the following steps to obtain a video ID:
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose Media Files > Audio/Video.
On the page that appears, obtain the video ID.
You can use the video ID that you obtained by using the ApsaraVideo VOD console to test the download and playback features. For more information about how to upload videos to ApsaraVideo VOD, see Overview.
What are the AccessKey ID and AccessKey secret? How do I obtain an AccessKey ID and AccessKey secret?
The AccessKey ID and AccessKey secret are the only credentials that you can use to call Alibaba Cloud APIs. The AccessKey ID is used to verify your identity. The AccessKey secret is used to encrypt the signature string of your access request. This prevents data from being tampered with. The AccessKey secret is similar to a logon password. Keep the AccessKey secret confidential.
Perform the following steps to obtain the AccessKey ID and AccessKey secret:
Log on to the ApsaraVideo VOD console.
Move the pointer over the profile picture in the upper-right corner and click AccessKey Management.
On the AccessKey Pair page, create an AccessKey pair or view the AccessKey secret of an existing AccessKey ID.
What is a playKey? How do I obtain a playKey?
A playKey is an API key. It is used for authentication when ApsaraVideo Player SDK obtains the playback URL of a video. Playback authentication is a secondary authentication mechanism that is implemented by ApsaraVideo VOD based on Alibaba Cloud AccessKey authentication. The playKey can prevent hotlinking. By default, ApsaraVideo VOD provides playKeys for Flash, HTML5, iOS, and Android to meet your video playback requirements.
To ensure security, you must enter the verification code that is sent to your mobile phone to view your playKey.
Perform the following steps to obtain the playKey:
Log on to the ApsaraVideo VOD console.
In the left-side navigation pane, choose
. On the Download page, turn on Download. In the Enable Download dialog box, select Secure Download and click OK.In the Get the key section, configure the Unique App Identifier and Private Key parameters.
Click Generate and Download Key.
What is a playAuth? How do I obtain a playAuth?
ApsaraVideo Player supports three playback modes that are suitable for different scenarios. Compared with other playback modes, playAuth-based playback is more secure. We recommend that you use the setAuthInfo mode for video playback.
playAuth is a playback credential in which the video ID, AccessKey ID, and AccessKey secret are packaged and encrypted. After you obtain the playAuth, you can use the string of data that contains various information to play videos in ApsaraVideo Player.
Playback mode | Scenario | Description | Recommended |
setDataSource | Testing | To use this playback mode, you must write your AccessKey pair to your client. If the client is cracked, your AccessKey pair may be leaked. | We recommend that you do not use this playback mode in your business environment. |
setAuthInfo | Commercial use | A secure playback mode. No video URLs or links are exposed. | We recommend that you use this playback mode in your business environment. |
URL-based playback | Playback of local videos and videos based on URLs | A simple playback mode that can be used to play videos on other platforms. | You can use this playback mode when you need to play local videos and online videos. |
Process: The server obtains a playAuth and sends the playAuth to the client. Then, the client plays the video.
You use ApsaraVideo VOD SDK to obtain a playback credential.
ApsaraVideo Player SDK obtains the playback URL of the video from ApsaraVideo VOD based on the video ID and playback credential. Then, ApsaraVideo Player SDK loads and decodes the video stream, and plays the video.
A playback credential is valid for 100 seconds and can be used to obtain only the playback URL of the specified video. Playback credentials cannot be reused. You cannot use an expired playback credential to obtain the playback URL. In this case, you must obtain a new playback credential.
ApsaraVideo Player SDK automatically obtains the playback URL, decodes the video, and then plays the video based on the playback credential. A playback URL is valid for 30 minutes. If your playback credential expires, obtain a new playback credential and pass it to ApsaraVideo Player SDK to refresh the playback URL.
To ensure the security of your Alibaba Cloud account, we recommend that you use the AccessKey pair of a RAM user, especially when you use ApsaraVideo Player SDK for Web.