API & Integration -> Quick Start
Inject RenderScript into a template
Between using a template and completely generating a video from RenderScript, there is a middle way that combines the ease of using templates with the flexibility of JSON.
Step 1Create a template
Perhaps you're working with highly dynamic data, and wish to generate part of your video based on certain parameters. For example, the number of elements varies from video to video, like this real estate video with dynamic shots based on the listing.If so, it makes sense to generate the video sequence with RenderScript, while maintaining a template for ease of editing. Let's look at this technique based on the following template:
Step 2Replace the video clips
As you can see, the template contains a composition named
Video-Composition. You can completely replace its content by targeting the composition's
elementsarray. To see this property structure in your template, view the RenderScript in the template editor (you can select the composition to jump directly to its section).In this example, we're replacing the existing video clips with two entirely different video elements.
curl -X POST https://api.creatomate.com/v2/renders \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY_HERE" \ -d '{ "template_id": "YOUR_TEMPLATE_ID_HERE", "modifications": { "Video-Composition.elements": [ { "type": "video", "track": 1, "source": "https://cdn.creatomate.com/demo/video1.mp4" }, { "type": "video", "track": 1, "source": "https://cdn.creatomate.com/demo/video2.mp4" } ] } }'
Step 3Append the video clips
You can also append new elements to an existing composition using the
addoperator, rather than replacing the entire content.In this example, we preserve the existing video clips and append two additional videos to the sequence. By assigning the new clips to the same track (track 1), they will be added to the existing timeline and play sequentially after the original videos (at about the 31-second mark).
curl -X POST https://api.creatomate.com/v2/renders \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY_HERE" \ -d '{ "template_id": "YOUR_TEMPLATE_ID_HERE", "modifications": { "Video-Composition.elements.add": [ { "type": "video", "track": 1, "source": "https://cdn.creatomate.com/demo/video1.mp4" }, { "type": "video", "track": 1, "source": "https://cdn.creatomate.com/demo/video2.mp4" } ] } }'