Adjust Video Loop Style
Loop Style
HeyGen API offers different loop styles to adjust how a video behaves within a scene, let's explore how each of these loop styles affects video rendering.
- Loop: The
loop
style ensures that the video keeps playing in a never-ending cycle until the end of the video track. - Fit to scene: When you select the
fit_to_scene
style, HeyGen adjusts the video's speed to match the scene's duration. It adjusts the video's playback speed to ensure the video's duration matches that of the scene. - Freeze: With the
freeze
style, HeyGen preserves the last frame of the video even after it finishes playing, maintaining it until the end of the video track.
You can view the example template video here.
Retrieve Template Variables
You can fetch the template variables using the following API call:
curl -X GET 'https://api.heygen.com/v1/template.get?video_id=<video_id>' \
-H 'X-Api-Key: <your-api-key>'
{
"code": 100,
"data": {
"scenes": [
{
"variables": [
{
"name": "video_0",
"properties": [
{
"default": "<url>",
"name": "link"
},
{
"default": "none",
"name": "play_style"
}
],
"type": "video"
}
]
}
],
"template_id": "c2735a01d43343babb9138528a68cd46",
"video_id": "c2735a01d43343babb9138528a68cd46"
},
"message": "Success"
}
Customize Template Variables and Generate Video
Now, you can proceed to replace the video's play_style
variable in your template. Use the following API request:
curl --request POST \
--url https://api.heygen.com/v1/template.generate \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'X-Api-Key: <your-api-key>' \
--data '
{
"template_id": "c2735a01d43343babb9138528a68cd46",
"title": "test sub video",
"test": true,
"variables": [
{
"properties": {
"play_style": "fit"
},
"name": "video_0"
}
]
}'
{
"code": 100,
"data": {
"video_id": "<video_id>"
},
"message": "Success"
}
Updated 4 months ago