Stream Video File - Direct Upload

This guide will show you how to upload video files to LiveAPI and get them ready for streaming to your audience.

There are 2 ways to upload a video to LiveAPI:

  1. Upload via 3rd-party URL
  2. Directly upload a file from a local machine

This article will explain how to upload video files directly from a local machine.

The process involves directly uploading the file to a provided link, making it not resumable. If there is an error in your network connectivity while uploading, it will require a start over.

Directly uploading files from your local machine is recommended for file size <5GB. For files that are >5GB in size, we recommend using the Multipart Upload feature that's coming soon.

Before You Begin

You need to have access to LiveAPI Access Token. Refer to the Authentication in LiveAPI section to learn how to generate an access token via the LiveAPI dashboard.

Step 1: Create a video object

You can make a POST /videos call to create a new video object.

Sample request:

curl --location --request POST 'https://api.liveapi.com/videos' \
--header 'Content-Type: application/json' \
--header 'Authorization: {your_authentication}'

Sample Response:

Here you will need the _id of the video object for moving on to the next step.

{
    "_id": "6215df773a13b3c407dc09u8",
    "playback": {
        "embed_url": "https://player.liveapi.com/vod/620e0ba1ce8f11ddde571d1c/vd9e8fe6e0947811ec82f5",
        "hls_url": "https://video.liveapi.com/620e0ba1ce8f11ddde571d1c/vd9e8fe6e0947811ec82f5.mp4/index.m3u8"
    },
    "user": "620e0ba1ce8f11ddde571d1c",
    "environment": "production",
    "organization": "620e0ba2ce8f11ddde571d1d",
    "creation_time": "2022-02-23T07:17:11.940Z"
}

Step 2: Get a Signed Link for Direct Upload

To generate a signed link for uploading a file to the video object you created in Step 1, use POST /videos/{video-id}/uploads with {video-id} taken from _id in Step 1.

Sample request:

curl --location --request POST 'https://api.liveapi.com/videos/6215df773a13b3c407dc09u8/uploads' \
--header 'Content-Type: application/json' \
--header 'Authorization: {your_authentication}'

Sample Response:

The response contains the Signed Link for Step 3.

{
    "url": "https://liveapi-storage.s3-accelerate.amazonaws.com/vod_uploads/623996689bae82d397a16f7e/vd7c638810a9c211ec8669.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAV5BGREJE3VXIKN46%2F20220322%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220322T092859Z&X-Amz-Expires=21600&X-Amz-Signature=00e81cc8881e75c3dba05f6b56f9743420d7ad71deb93b8d5e0f984ef77d05cd&X-Amz-SignedHeaders=host"
}

🚧

Signed Link expiration

The Signed Link expires after 6 hours from creation time, and you won't be able to upload to that link anymore.

Step 3: Upload a local video file to the Signed link location

Once you get the Signed link from Step 2, you can start uploading your file.

Sample request:

Replace the --data-binary field with the local link to your file.

curl --location --request PUT 'https://liveapi-storage.s3-accelerate.amazonaws.com/vod_uploads/623996689bae82d397a16f7e/vd7c638810a9c211ec8c43.mp4?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAV5BGREJE3VXIKN46%2F20220322%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20220322T092859Z&X-Amz-Expires=21600&X-Amz-Signature=00e81cc8881e75c3dba05f6b56f9743420d7ad71deb93b8d5e0f984ef77d05cd&X-Amz-SignedHeaders=host' \
--header 'Content-Type: application/json' \
--data-binary '@/C:/Users/tamhm/Files/Sample_Video_LiveAPI.mp4'

After uploading the video file successfully, the response will return a 200 success code. Then you can call to GET /videos/{id} to retrieve the video details with the {id} being the video identifier.

If you wish to know more about how Direct Link Upload works, please visit this article from AWS.


πŸ“˜

Supported Formats

LiveAPI supports all formats which ffmpeg supports. For the full list, you can refer to here.

Webhook supported for Video

You can get a list of webhook events we supported for Video here.


Did this page help you?