Skip to content

Upload HLS Streaming fragmented files to Azure Blob Storage and pre-load a part of the stream.

License

Notifications You must be signed in to change notification settings

ilseokoh/azurehlsupload

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

한국어 버전

Upload HLS Streaming contents to Azure Blob Storage and request CDN pre-load with Azure Functions

This application upload HLS streaming contents to Azure Blob Storage using Azure Functions and request CDN pre-loading using Azure CDN REST API.

Development Tools

Diagram

Block Diagram

Process

  1. Request upload item to /api/upload API (RequestUploadFunction)
  2. Parse HLS URL to recognize all the files need to copy and insert Azure Queue with 10 items (M3u8UrlParseFunction)
  3. ContentUploaderFunction tirgger by Queue and upload 10 items to Azure blob storage (ContentUploaderFunction)
  4. Monitor the progress using /api/monitor and /api/status API (MonitorUploadFunction, UploadStatusFunction)

API Spec

Code runs on Azure App Services.

업로드 요청

  • Request URL: http://{app-service-name}.azurewebsites.net/api/upload?code={secretcode}}
  • Method: POST
  • Header
    • Content-Type: application/json
  • Body
    • primaryUrl : Main playlist URL
    • secondaryUrls: Secondary playlist URL
  • Request
{
   "primaryUrl": "https://{hostname}/playlist_1080.m3u8",
    "secondaryUrls" : [
        "https://{hostname}/playlist_720.m3u8",
        "https://{hostname}/playlist_480.m3u8",
        "https://{hostname}/playlist_360.m3u8",
        "https://{hostname}/playlist_300.m3u8"
    ]
}
  • Response: Success (200)
{
   "status": "success",
   "data": "",
   "message": "requested: http://{hostname}/playlist_1080.m3u8"
}
  • Response: Failed (500)
{
   "status": "error",
   "data": "{request body}",
   "message": "{error message}"
}

Status

  • Request URL: http://{app-service-name}.azurewebsites.net/api/status?code={secret-code}
  • Method: POST
  • Body: primaryUrl by string (not json)
  • Response 성공(200)
{
   "url": " http://{hostname}/playlist_1080.m3u8",
   "fileCount": 3271,
   "completeCount": 866,
   "progress": 0.2647508407214918985019871599,
   "hasError": false
}
fileCount Total file count
completeCount Complete Count
progress (fileCount / complete)

Monitor

  • Request URL: http://{app-service-name}.azurewebsites.net/api/monitor?code={secretcode}
  • Method: GET
  • Response: Success(200)
{
  "totalCount": 9,
  "errorCount": 1,
  "ongoingCount": 3,
  "ongoingList": [
    {
      "url": "http://odkcdn1.azureedge.net/72sec/playlist_1080.m3u8",
      "fileCount": 3457,
      "completeCount": 902,
      "progress": 0.2609198727220133063349725195,
      "hasError": false
    },
    {
      "url": "http://odkcdn1.azureedge.net/infinite-challenge/infinite-challenge-e528/playlist_720.m3u8",
      "fileCount": 3271,
      "completeCount": 891,
      "progress": 0.2723937633751146438398043412,
      "hasError": false
    },
    {
      "url": "http://odkcdn1.azureedge.net/youns-kitchen/youns-kitchen-e7/playlist_720.m3u8",
      "fileCount": 3589,
      "completeCount": 1521,
      "progress": 0.4237949289495681248258567846,
      "hasError": true
    }
  ],
  "errorList": [
      {
      "url": "http://odkcdn1.azureedge.net/youns-kitchen/youns-kitchen-e7/playlist_720.m3u8",
      "fileCount": 3589,
      "completeCount": 1521,
      "progress": 0.4237949289495681248258567846,
      "hasError": true
    }
  ]
}
totalCount Total Content count
errorCount Content count that has error
ongoingCount Content count that is uploading
ongoingList Detail list of uploading content
errorList Detail List of error content
- Response: Failed (500)

CDN Pre-load

Azure CDN can be set the origin using Azure blob storage. But uploaded contents won't cache on CDN immediately. One or more requests of the content need to cache them. Pre-load request is very useful to improve CDN performance. Azure CDN pre-load feature has limit, 10 urls per minute, and it will take 2-3 minutes to finish pre-load. So the code request only 100 seconds of the content.

Reference for Azure CDN Pre-load

About

Upload HLS Streaming fragmented files to Azure Blob Storage and pre-load a part of the stream.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages