pythonamazon-web-serviceswebdavaws-media-liveaws-mediapackage

Ingesting HLS into Mediapackage


I have the following setup for a streaming app. EMX -> EML -> S3 -> LAMBDA -> EMP. When I try to make a put request to mediapackage hls ingest endpoint, I get a 201.

def postStreamToMediaPackage(envVariables, fileName, content, contentType):
    mediaPackageUrl = envVariables["url"]
    username = envVariables["username"]
    password = envVariables["password"]
    ingestUrl = f"{mediaPackageUrl.rstrip('/channel')}/{fileName}" # not sure what mediapackage wants.

    response = requests.put(
        ingestUrl, data=content, headers={
            "ContentType": contentType
        }, auth=HTTPDigestAuth(username, password))
    if response.status_code != 201:
        print(
            f"Error ingesting file {fileName} to {ingestUrl}. error: {response.text}")
    return {"ingestUrl": ingestUrl, "fileName": fileName, "status": response.status_code}

But if i check mediapackage ingress access logs,

I've tried everything I can to get a positive response from mediapackage origin endpoint but it always returns a 404 for manifest.

Mediapackage hls ingest is a webDav server.

Has anyone tried doing this? I can't find any useful doc that says how they expect these.


Solution

  • After a lot of twiddling and tinkering, we discovered that mediapackage needs the following file name structure to get a successful push.

    if fileName == "index.m3u8": # this is your root manifest
      ingestUrl = f"{mediaPackageUrl}.m3u8"
    else:
       ingestUrl = mediaPackageUrl.replace('channel', fileName) # for all other resources, you need to feed it to the root endpoint.