Upload a video from local storage with the Wowza Video REST API

Wowza Video™ allows users to ingest, store, and categorize video content in order to centralize, reuse, amplify, and provide user-friendly access to videos.

This article demonstrates how to upload .mp4 files stored on your local computer to Wowza Video using the Wowza Video REST API.

Info

This topic only applies to version 2.0 and later of the REST API.

Before you start

You should be familiar with the following concepts:

  • API authentication methods . We use JSON web tokens for API authentication. See Authentication for more information.
  • Environment variables . We use environment variables for the API version and your JWT in the cURL API request examples in this topic to make it easier for you to copy, paste, and run commands in your Terminal or Command Prompt window. If you don't set environment variables for these values, you'll need to manually enter the correct values in the code samples throughout this tutorial. See Tools for testing the API for instructions.

1. Create an object in Wowza Video to store your video asset

Before you can upload a video from your local storage to Wowza Video, you'll need to create a storage location in Wowza Video by sending a POST request to the /videos endpoint.

You can use the following sample request, making sure to:

  • Specify DIRECT for the input or upload method. Wowza Video will return an upload URL you'll use in step 2 to upload the video from your local storage.
  • Set any other information you'd like to now, like the video name and description. You can always set these values later using PATCH /video/ID .
    Info

    To categorize a video, you'll need to already have an existing category so you can pass the category ID in this request.

Sample request
Endpoint Reference

Copy
Copied
curl -X POST \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${WV_JWT}" \
-d '{
      "video": {
        "input": {
          "method": "DIRECT"
        },
        "name":"My video"
      }
}' "${WV_HOST}/api/${WV_VERSION}/videos"

Sample response

The response includes:

  • An id for the asset that you'll use to complete other actions on the asset.
  • An upload_url for the video that you'll use in step 2 to upload the asset to Wowza Video.

The response might look similar to the following code:

Copy
Copied
{
  "video": {
    ...
    "id": "fc5b04bc-7bf6-468e-ae88-afdb1873a6c4",
    "name": "My video",
    "upload_url": "<secure_upload_url>"
    ...
  }
}

2. Upload the video to Wowza Video

You can upload the file with the cURL --upload-file option.

Info

We support multiple video and audio formats, but we recommend MP4 format and H.264 and AAC encoded files.

You can use the following sample request, making sure to:

  • Set upload_url to the upload_url returned when you created the asset.
  • Set file_path to the location on your computer for the file you would like to upload.

    For example, ~/Downloads/MyFile.mp4

Sample request

Copy
Copied
curl -X PUT -H 'Content-Type: video/mp4' --upload-file file_path 'upload_url'

This is the sample request using the file_path and upload_url from the previous step:

Copy
Copied
curl -X PUT -H 'Content-Type: video/mp4' --upload-file MyFile.mp4 'https://objectstorage.us-ashburn-1.oraclecloud.com/p/k9bGRcyPFPtdeQeTRgAVTByIVVS0Z_EKrLBu3TusTrRfBuIpoDyio_ZYdjdjfkf/n/a1b2c3d4e5f6/b/myfolder/o/uploads/recording_bry7vv0s/myvideo.mp4';
Info

If you are manually walking through these steps and would like additional error reporting as well as a visual indicator on the command line regarding upload status, you can append a log-to-file command to the cURL request above: log_file.out

You'll get a log file written locally and upload status in the command line while the file is uploading, like:

log file

When you upload the video to Wowza Video, we'll transcode your MP4 so that you'll also have an HLS stream that ensures the best viewing experience possible. If you want to check the transcoding status of your video, you can send a POST request to /videos/ID, where ID is the ID returned in step 1.

Related API requests