Uploading and watching an asset is easy! The example below uses the Create Asset API to create an upload URL to upload a video.

Livepeer supports resumable uploads through the TUS protocol, which helps with reliability and efficiency when transferring large assets. This is the recommended approach for uploading media files.

Livepeer provides two options for uploading assets:

  • TUS Resumable Upload (recommended for all use-cases): TUS uploads ensure reliability and efficiency when transferring media files. It is recommended for all use-cases, as it is compatible with all modern browsers and supports resuming uploads.
  • PUT Upload: Upload assets via simple HTTP verbs for processing and play back.

Using Livepeer’s SDKs

We can use one of the Livepeer SDKs to create a TUS-compatible upload endpoint.

We can then use TUS on the frontend to directly upload the asset to Livepeer.

import { Livepeer } from "livepeer";

const apiKey = 'YOUR_API_KEY';
const fileName = 'filename.mp4';

const livepeer = new Livepeer({apiKey});

const assetData = {
  name: fileName
};

livepeer
  .asset.create(assetData)
  .then((response) => {
    console.log("Asset upload request:", response);
  })
  .catch((error) => {
    console.error("Error requesting asset upload:", error);
  });

// pass the TUS endpoint to the frontend and use TUS to upload
// https://github.com/TUS/TUS-js-client

Once an upload endpoint is created, you can use it to upload your video file to Livepeer. The upload endpoint is TUS compatible, so you can use any TUS-compatible client (like TUS-js-client) to upload your video file from the frontend.

For rapid processing of assets that will also be archived on IPFS or Arweave, we strongly encourage either (1) uploading to Livepeer with the IPFS storage option enabled, or (2) uploading the raw file to the API prior to archiving on dStorage, rather than passing the IPFS / Arweave gateway URL. The gateway URL will work, but may incur longer-than-usual processing time.

IPFS and Arweave sources

IPFS is a network of nodes that allow you to read content from the network using a content identifier unique to the data you’re requesting, ensuring you are able to verifiably get exactly what you are asking for, regardless of where the data is physically stored. Arweave is a set of nodes that are incentivized to store data permanently; content stored on the network is pulled through an Arweave gateway.

Play an asset

To learn how to play an asset, see the Play an Asset guide.