With video content, one of the core ways businesses stand out and establish ownership of the content is through watermarks.

To watermark a video using the VEED API, you need to follow 4 simple steps as shown below:

1. Get your API keys

This is most crucial because the only way to interact with our API is by using your API keys for authentication. If you do not have this handy already, follow the instructions here to retrieve them.


2. Construct the Render Object

Once you have your API keys, the next step is to construct the render object. Our render object for this use case will have 2 elements i.e a video element and a text element. The video specifies the video which is to be watermarked while the text would is to be layered on the video as a watermark.


๐Ÿ‘

Watermark assets

Note that, you can add both text and image watermarks depending on your use case. You simply need to specify the appropriate render element.


{
    "elements":[
        {
            "type":"video",
            "params":{
                "source":{
                    "url": 'https://storage.googleapis.com/veed-docs/sample-video.mp4'
                }
            }
        },
        {
            "type":"text",
            "params":{
                "value":"WATERMARK",
                "style":{
                    "font":"Helvetica",
                    "size":48.0,
                    "display":"normal",
                    "color":"#FFFFFF",
                    "secondary_color":"#ffffff",
                    "align":"center",
                    "line_height":0.0,
                    "letter_spacing":0.0,

                },
                "position":{
                    "origin":"bottom left",
                    "x":0.5,
                    "y": 1.0
                },
                "z_index":1
            }
        }
    ]
}

3. Sending the request

Now that we have our render object created, we need to send a request to start the rendering process.

To test this from your terminal, you can save the object above to a file called render.json. Then, from the directory where the file is saved, run the curl command below with the file name as the POST body. Make sure to change the API key to match the one from your dashboard.

curl \
  -X POST \
  --header "Content-Type: application/json" \
  --header "Authorization: key_test_XXXXXXXXXXXXXX" \
  --data @render.json \
  https://api.veed.io/api/renders

If the render request is successfully queued, you will get a response like this:

{
  "id": "b477e483-592a-4bc6-a22b-563ef7f48e25"
}

The returned id represents the task that is in charge of rendering. The id can be used to track the progress of the render and get the final result when it has been completed.

๐Ÿ“˜

If using webhooks

If you already have a webhook configured on your dashboard, you will automatically receive a message whenever the status of a render changes.


4. Getting the final render

In this example, we will get the result by polling the API. Alternatively, you can use the webhook method (which we recommend - find out more, here).

As soon as you get the response, you can start polling the API, using the id returned earlier:

curl \
  --header "Authorization: veed_test_XXXXXXXXXXXXXXXX" \
  https://api.veed.io/api/renders/{your-render-id}

You will now get a new response, which will tell you the status: QUEUED , PROGRESS , SUCCESS, FAILED.

If your rendering pool is empty, the request should start immediately and your first response should be of type RENDER/PROGRESS , which will look like this:

{
    "type": "RENDER/PROGRESS",
    "payload": {
      "id": "b477e483-592a-4bc6-a22b-563ef7f48e25",
      "progress": 56,
    }
  }

Inside the payload object you will get a progress field, which indicates the percentage of rendering that has been completed. Once it reaches 100, your render is done and you need to poll the API once more.

curl \
  --header "Authorization: veed_test_XXXXXXXXXXXXXXXX" \
  https://api.veed.io/api/renders/b477e483-592a-4bc6-a22b-563ef7f48e25

This time you should get a response of type RENDER/SUCCESS.

{
    "type": "RENDER/SUCCESS",
    "payload": {
      "id": "b477e483-592a-4bc6-a22b-563ef7f48e25",
      "progress": 100,
      "url": "https://cdn.veed.dev/R1vqZ0KfPp5y2z7ddiTyt.mp4"
    }
  }

Now that you have the url, you can download the resulting render and enjoy your new video!