> ## Documentation Index
> Fetch the complete documentation index at: https://documentation.bannerify.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Render videos in Go

> Render a video template as an MP4 and follow its progress with the Go SDK.

A video template renders as an MP4. Each second of the video counts as one generation. [Generate videos](/docs/essentials/generate-videos) explains how to design one.

Both methods take a context, a template id, and the modifications.

<ParamField body="templateID" type="string" required>
  The id of a video template, for example `tpl_xxx`.
</ParamField>

<ParamField body="modifications" type="[]bannerify.Modification">
  The values to put into the template's layers. A video layer takes a `Src`, and the modification named `music` changes the music. [Modifications](/docs/essentials/modifications) lists the fields each layer accepts.
</ParamField>

## Render and wait for the URL

`RenderAndWaitVideo` returns the URL of the MP4. The error is an `*ErrorResponse`.

```go theme={null}
headline := "Summer sale"
url, err := client.RenderAndWaitVideo(ctx, "tpl_xxx", []bannerify.Modification{
	{Name: "headline", Text: &headline},
})
if err != nil {
	log.Fatal(err)
}

fmt.Println(url)
```

## Follow the progress

`RenderVideo` returns an `iter.Seq[RenderVideoEvent]`. The last event is `done` or `error`.

```go theme={null}
for event := range client.RenderVideo(ctx, "tpl_xxx", nil) {
	switch event.Type {
	case "queued":
		fmt.Printf("%d videos before this one\n", event.Ahead)
	case "progress":
		fmt.Printf("%.0f%%\n", event.Progress*100)
	case "done":
		fmt.Println(event.URL)
	case "error":
		fmt.Println(event.Error)
	}
}
```

| Event | Fields |
| - | - |
| `queued` | `Ahead`: the number of videos before this one |
| `progress` | `Frame`, `TotalFrames`, and `Progress` from 0 to 1 |
| `done` | `URL`: the URL of the MP4 |
| `error` | `Error`: `Code`, `Message`, and `RequestID` |

A refused request, such as an invalid API key or a used-up quota, gives one `error` event. The client timeout does not apply to a render, because a video can wait in line for minutes. Cancel `ctx` to stop.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.