Upload a video asset
This guide provides you the instructions to upload a video from the Livepeer Studio Dashboard or through the Livepeer API.
The Livepeer API allows you to send video files to Livepeer and get them ready for optimized playback. Videos can be provided either by you (static content) or your users, given your application offers an interface for them to do so.
Caveats
- Files are currently limited to 1GB in size. Any files greater than that will likely error out during the upload or processing steps.
- Only MP4 files encoded with H.264 and AAC are supported
Uploading via URL
When using the upload via URL method:
- Provide the name of the asset
- Provide the URL of the asset that should be imported
Step 1: Upload asset by URL
To upload the asset to the Livepeer network, you'll need to make a POST request and include the URL of the asset to be uploaded.
- Node
- curl
const uploadAssetURL = await fetch("https://livepeer.studio/api/asset/import", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
"Content-Type": "application/json",
},
data: JSON.stringify({
url: "$EXTERNAL_URL"
name: "Example name",
}),
});
curl --location --request POST 'https://livepeer.studio/api/asset/import' \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"url":"$EXTERNAL_URL",
"name":"Example name"
}'
Step 2: Check the upload status
After uploading your asset, get the asset.id
from the
response object of the POST
request. The asset.id
represents the status of your upload.
When asset.status: "ready"
is returned in the response, the asset has finished
uploading and will be ready for playback. If asset.status: "waiting"
is
returned in the response, the asset is not available yet and you should make the
API call again until asset.status: "ready"
.
- Node
- curl
const getAsset = await fetch("https://livepeer.studio/api/asset/{id}", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
"Content-Type": "application/json",
},
});
curl --location --request GET 'https://livepeer.studio/api/asset/{id}' \
--header 'Authorization: Bearer $API_TOKEN'
Uploading Locally
Step 1: Generate upload URL
To upload the asset to the Livepeer network locally, you'll need to make a POST request to generate an upload URL.
- Node
- curl
const uploadAsset = await fetch(
"https://livepeer.studio/api/asset/request-upload",
{
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_TOKEN}`,
"Content-Type": "application/json",
},
data: JSON.stringify({
name: "Example name",
}),
}
);
curl --location --request POST 'https://livepeer.studio/api/asset/request-upload' \
--header 'Authorization: Bearer $API_TOKEN' \
--header 'Content-Type: application/json' \
--data-raw '{
"name":"Example name"
}'
Step 2: Upload your video to the URL
Get the "url": "https://origin.livepeer.studio/api/assets/…"
from the
response object. Using the URL
generated, upload your video with a PUT request.
- Node
- curl
const uploadAsset = await fetch("${url}", {
method: "PUT",
headers: {
Authorization: `Bearer ${process.env.LP_API_KEY}`
"Content-Type": "video/mp4"
},
data: fs.createReadStream(path)
});
curl --location --request PUT "${url}" \
--header 'Content-Type: video/mp4' \
--data-binary '@$VIDEO_FILE_PATH'
Step 3: Check the upload status
After uploading your asset, get the asset.id
from the
response object of the POST
request. The asset.id
represents the status of your upload.
When asset.status: "ready"
is returned in the response, the asset has finished
uploading and will be ready for playback. If asset.status: "waiting"
is
returned in the response, the asset is not available yet and you should make the
API call again until asset.status: "ready"
.
- Node
- curl
const getAsset = await fetch("https://livepeer.studio/api/asset/{id}", {
method: "GET",
headers: {
Authorization: `Bearer ${process.env.LP_API_KEY}`,
},
});
curl --location --request GET 'https://livepeer.studio/api/asset/{id}' \
--header 'Authorization: Bearer $API_TOKEN'