Livepeer Studio

Directly Upload an Asset

To manually upload an asset to the Livepeer platform, your first need to request for a direct upload URL and only then actually upload the contents of the asset.

This also allows your users to upload files directly to Livepeer, since the upload URL is pre-signed with your credentials and is accessible from the browser. The initial API call to get the upload URL must be done from a backend though, from which an API token is available.

First generate a URL to directly upload a video Asset to Livepeer on POST /api/asset/request-upload:

curl

curl --location --request POST 'https://livepeer.studio/api/asset/request-upload' \
--header 'Authorization: Bearer {api_key}' \
--header 'Content-Type: application/json' \
--data-raw '{
    "name":"Example name"
}'

JavaScript + axios

const axios = require("axios");

axios
  .post("https://livepeer.studio/api/asset/request-upload", {
    headers: {
      Authorization: "Bearer {api_key}",
      "Content-Type": "application/json",
    },
    data: JSON.stringify({
      name: "Example name",
    }),
  })
  .then((res) => {
    console.log(JSON.stringify(res.data));
  })
  .catch((error) => console.log(error));
parametertypedescription
namestringThe name of the `Asset` containing a custom human-readable description or title.
{
    "url": "https://origin.livepeer.studio/api/asset/upload/aHR0cHM6Ly9zdG9yYWdlLmdvb2dsZWFwaXMuY29tL2xwLW55Yy12b2QtbW9uc3Rlci9kaXJlY3RVcGxvYWQvNjI3OHQyZWlrY2JqZXUxNC9zb3VyY2U%2F...",
    "asset": {
        "id": "$ASSET_ID",
        "name": "Example name",
        "playbackId": "$PLAYBACK_ID",
        "userId": "$USER_ID",
        "createdAt": 1644595454248,
        "status": {
          "phase": "waiting",
          "updatedAt": 1644595454248
        }
    },
    "task": {
        "id": "$TASK_ID",
        "type": "import",
        "outputAssetId": "$ASSET_ID",
        "params": {
          "import": {
            "uploadedObjectKey": "directUpload/$PLAYBACK_ID/source"
          }
        },
        "createdAt": 1652813126031,
        "status": {
            "phase": "pending",
            "updatedAt": 1652813126031
        }
    }
}

You can use the returned task object to monitor the progress of processing the asset after the contents have been uploaded. Check the Retrieve a Task API for more information.

Now upload (PUT) a video file on the exact URL in the url field of the response above:

curl

curl --location --request PUT "${url}" \
--header 'Content-Type: video/mp4' \
--data-binary '@$VIDEO_FILE_PATH'

JavaScript + axios

const axios = require("axios");

axios
  .put(`${url}`, {
    headers: {
      "Content-Type": "video/mp4",
    },
    data: "@$VIDEO_FILE_PATH",
  })
  .then((res) => {
    console.log(JSON.stringify(res.data));
  })
  .catch((error) => console.log(error));

Notice that we only support mp4 files encoded with H264 video and AAC audio for now. If you are unsure about these, try sending the file anyway and check any returned errors!