Where to store NFTs (non-fungible tokens) is just as important as what type of NFTs to create. In the process of making them, storage is an essential part of it as it allows the NFTs to be preserved.
IPFS, short for Interplanetary File System, has been around for a while, which means its network has had time to mature and be reliable. Their protocol is used by the majority of projects that utilize decentralized storage, including NFTs. By exporting assets to IPFS, not only will they generate a unique fingerprint called content identifier (CID) for the NFTs, but also this data will be preserved due to the support of their community for maintaining and expanding their decentralized ecosystem.
Livepeer Studio makes the process of exporting to IPFS easy by using the Video on Demand (VoD) API. With a simple step, assets that get uploaded to Livepeer Studio will have the option to be exported to IPFS. Once the asset has been exported they are ready to be minted. This reduces the process of transcoding the assets and then taking that transcoded asset from Livepeer Studio and then using IPFS.
In this tutorial, we will look at the ease of using the VoD API to upload assets to Livepeer Studio and then export them to IPFS.
Access to a free Postman and Livepeer Studio account is required. Visit How to make API calls with Postman and Livepeer Studio tutorial for instructions on getting set up.
There are two ways to provide Livepeer with assets for VoD, either importing or uploading the asset. The following steps address how to implement both.
{
“url”: ”https://www.pexels.com/video/5613843/download/”,
"name": "JellyFish"
}
This is a two-step process that allows the user to provide the asset by directly uploading to Livepeer Studio.
{
"name": "JellyFish"
}
Now that the URL for direct upload is created, time to upload the content.
*Copy the URL and the ID of the asset/task from the response for the next part.
https://origin.livepeer.com/api/asset/upload/eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJwcmVzaWduZWRVcmwiOiJodHRwczovL3N0b3JhZ2UuZ29vZ2xlYXBpcy5jb20vbHAtdXMtdm9kLWNvbS9kaXJlY3RVcGxvYWQvZWIyMG01cDdqd3d1bDZ3OS9zb3VyY2U_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ29udGVudC1TaGEyNTY9VU5TSUdORUQtUEFZTE9BRCZYLUFtei1DcmVkZW50aWFsPUdPT0cxRVlVTldOVjZSWUlLNTQySFdBM1JMN1JCN0pVT0VRM1lMMjNRWUI2Q0hQRzVITzJRQzMzTUpWVVklMkYyMDIyMDQyMSUyRnVzJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDIyMDQyMVQxNDM1NTNaJlgtQW16LUV4cGlyZXM9OTAwJlgtQW16LVNpZ25hdHVyZT1iZGZhOGNlYWVkNDg2YWIyMzYyZmJkMzA0MGRlNjA4MjM0ZmQ0YWU0ODIyYTE4NzBmMzhiZTRiMDFiZmZhZWE1JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZ4LWlkPVB1dE9iamVjdCIsImF1ZCI6Imh0dHBzOi8vbGl2ZXBlZXIuY29tIiwiaWF0IjoxNjUwNTUxNzUzfQ.ujURa40V95ETrUrjYi4Ho5vD3g5-5l_5o0kJfJNUMiA
*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!
We need to check to make sure that the asset is ready before exporting it since it can take some time to upload.
For the asset ID here, use the asset.id field in the response to the Import or Request Upload requests above.
https://livepeer.com/api/asset/:assetId
status:“ready”
. If it is status:“waiting”
, then wait a little longer and repeat this step until the status is ready before moving to the exporting step.https://livepeer.com/api/asset/$ASSET_ID/export
*The $ASSET_ID is located in the response body from step 1A or 1B depending on the method you chose.
{ “ipfs”: { } }
*IPFS is a complex protocol and so the export task can take a while. Expect this to take a bit longer than the import task
*Copy the ID of the task from the response for the next part.
For the task ID here, use the task.id field in the response of the Export request above.
https://livepeer.com/api/task/:taskId
IPFS locates the content based on what is inside of it rather than by the location, CID is what allows it to do this.
To Get the CID and metadata URL for the asset that was just exported, you can get it by retrieving the task above until it is finished (check the status field in the response). That finished task will have an output with all the information about that asset, and the CID information is located under the output.export.ipfs path. See the image below:
As you can see here, information such as the video file’s CID, location of the URL on IPFS, and other metadata information.
With the ability to upload assets and export them to IPFS easily with Livepeer Studio’s VoD API, those assets can now be stored in decentralized storage and be accessible.
Start creating your own VoD Dapps and store them in decentralized storage.
Take it to the next level by minting video NFTs using Livepeer Studio video NFT SDK.