Overview
This topic describes how to obtain the streaming URL of a live stream and generate a signed streaming URL.
Obtain a streaming URL
- From the console:
- URL generator page
In the ApsaraVideo Live console, go to to generate a streaming URL. For detailed steps, see Use the URL generator.
- Stream management page
In the ApsaraVideo Live console, go to . Find the ingest URL that you want and click View URLs to view its streaming URLs for different transcoded formats and protocols.
- URL generator page
- Use the concatenating rules
You can manually construct a streaming URL by using the concatenating rules. For more information, see Generate ingest and streaming URLs.
Obtain a signed streaming URL
The validity period of signed URLs from ApsaraVideo Live is short. To obtain a signed URL with a longer validity period, you can use a tool or an algorithm.
- Use a tool in the console
You can use a tool in the ApsaraVideo Live console to generate a signed streaming URL. For more information, see Configure URL signing.
- Use an algorithmYou can construct an unsigned streaming URL based on the AppName and StreamName parameters in an ingest URL. Example:
rtmp://videolive.aliyuntest.club/AppName1/StreamName1. Then, you can calculate a signed streaming URL by using the authentication algorithm. For more information, see Signed URL Components. The following sample PHP code provides an example://http://DomainName/Filename?auth_key=timestamp-rand-uid-md5hash //sstring = "URI-Timestamp-rand-uid-PrivateKey" (The URI specifies the relative address that points to the requested resource, such as /Filename.) //HashValue = md5sum(sstring) function PrivateKeyA(){ $time=strtotime("-800 seconds");//("+1 hours"); $key="aliyun2013"; $domain="rtmp://videolive.aliyuntest.club"; $filename="/AppName1/StreamName1"; //$sstring = "URI-Timestamp-rand-uid-PrivateKey" $sstring = $filename."-".$time."-0-0-".$key; $md5=md5($sstring); $auth_key="auth_key=".$time."-0-0-".$md5; $url=$domain.$filename."?".$auth_key; echo $url."\n"; }
Use code to obtain a streaming URL
You can construct an unsigned streaming URL based on the AppName and StreamName parameters in an ingest URL. For example, if the ingest URL is rtmp://video-center.alivecdn.com/APPName1/StreamName1?vhost=videolive.aliyuntest.club, the streaming URL is rtmp://videolive.aliyuntest.club/AppName1/StreamName1.
You can construct a signed URL by using the concatenating rules. For more information, see Signed URL Components. You can also use an algorithm to obtain a signed URL. The following sample code provides an example on how to calculate the signed URL for a streaming URL, such as rtmp://live8.aliyuntest.club/AppName1/StreamName1, based on the authentication algorithm.
//http://DomainName/Filename?auth_key=timestamp-rand-uid-md5hash
//sstring = "URI-Timestamp-rand-uid-PrivateKey" (The URI specifies the relative address that points to the requested resource, such as /Filename.)
//HashValue = md5sum(sstring)
function PrivateKeyA(){
$time=strtotime("-800 seconds");//("+1 hours");
$key="aliyun2013";
$domain="rtmp://videolive.aliyuntest.club";
$filename="/AppName1/StreamName1";
//$sstring = "URI-Timestamp-rand-uid-PrivateKey"
$sstring = $filename."-".$time."-0-0-".$key;
$md5=md5($sstring);
$auth_key="auth_key=".$time."-0-0-".$md5;
$url=$domain.$filename."?".$auth_key;
echo $url."\n";
}
What to do if a streaming URL cannot be used for normal playback
Scenario
After a stream is ingested, the streaming URL cannot be used to play the stream.
Troubleshooting
- Check whether the domain name is configured for live streaming.
Log on to the ApsaraVideo Live console, and check whether you can find the domain name on the Domains page.
- Check whether the stream ingest is successful. For more information, see Troubleshoot abnormal stream ingest.
- Confirm that live stream acceleration is working correctly.
Verify that you have added a CNAME record with your DNS provider. This record must point your streaming domain to the CNAME address that ApsaraVideo Live provides. For instructions, see Configure a CNAME record for a domain name. You can find the CNAME address in the CNAME column for your domain on the Domains page.
- Check whether the streaming URL is valid. For more information, see Obtain a streaming URL.
- Check whether URL signing is enabled for the domain name.
For information about how to determine whether the streaming URL is signed, see Generate ingest and streaming URLs.
- Check whether URL signing is enabled for the domain name and whether the streaming URL is expired. You can generate a new signed URL and check whether it can be used for playback.
- Check whether the player supports the video format. You can use VLC media player to check whether the video can be played.