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.

Livepeer provides two options for uploading assets:

  • PUT Upload: Upload assets via simple HTTP verbs for processing and play back.
  • Tus Resumable Upload: Discover the power of resumable uploads, ensuring reliability and efficiency when transferring your media files.

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.