How to create video with images

Hello,
I use API to create video from images

  1. I want to create a video from photos. I want to use a template, but it shows an error saying “template is not allowed”.

So, can I use a template for this part or not?

  1. I want to add music to the video I create. What should I do?

This is my payload

{
  "timeline": {
    "background": "#000000",
    "tracks": [
      {
        "clips": [
          {
            "asset": {
              "type": "image-to-video",
              "src": "https://d1hjkbq40fs2x4.cloudfront.net/2017-08-21/files/landscape-photography_1645.jpg",
              "template": "4e975845-8581-48a0-bde0-520c4f323e70",
              "prompt": "Slowly zoom in and out for a dramatic effect."
            },
            "start": 0,
            "length": 2
          },
          {
            "asset": {
              "type": "image-to-video",
              "src": "https://focusasiatravel.vn/wp-content/uploads/2021/04/trantuanviet-bavi-hanoi-1617326198.jpg",
               "template": "4e975845-8581-48a0-bde0-520c4f323e70",
              "prompt": "Rotate slowly and zoom out for a dynamic look."
            },
            "start": 2,
            "length": 3
          } 
        ]
      }
    ]
  },
  "output": {
    "format": "mp4",
    "resolution": "1080"
  }
}

This doesn’t look like valid JSON code. The image to video asset doesn’t take a template property.

You can render templates by calling the render template endpoing and referencing the merge fields.

It should look something like this:

POST https://api.shotstack.io/v1/templates/render

With the payload referencing the template id and the merge fields you’d want to use:

{
    "id": "ca84c7c5-5fe4-66d3-839e-ee0f1d4c2641",
    "merge": [
        {
            "find": "URL",
            "replace": "https://shotstack-assets.s3-ap-southeast-2.amazonaws.com/footage/city-timelapse.mp4"
        },
        {
            "find": "TRIM",
            "replace": 3
        },
        {
            "find": "DURATION",
            "replace": 10
        }
    ]
}