---
title: "Animated Previews (og:video)"
description: "Render a template's CSS animations to an MP4 and emit og:video tags for clients that play video previews."
canonical_url: "https://nuxtseo.com/docs/og-image/guides/og-video"
---

> Index of every page on this site: [llms.txt](https://nuxtseo.com/llms.txt)

Messages on iOS and macOS downloads an MP4 `og:video` and plays it automatically in the link preview ([Apple TN3156](https://developer.apple.com/documentation/technotes/tn3156-create-rich-previews-for-messages)). Set `video`, and the module renders your Takumi template's CSS animations to an MP4. The MP4 has the image's URL with an `.mp4` extension. `video: true` renders 3 seconds at 30 fps.

```vue [pages/invite/[code\\].vue]
<script lang="ts" setup>
const code = String(useRoute().params.code)

useSeoMeta({ title: `Join Beaver · Invite code: ${code}` })

defineOgImage('Invite.takumi', { code }, { video: { durationMs: 2000, fps: 30 } })
</script>
```

```vue [components/OgImage/Invite.takumi.vue]
<script lang="ts" setup>
defineProps<{ code: string }>()
</script>

<template>
  <div class="h-full w-full flex items-center justify-between bg-black px-24">
    <p class="text-9xl font-bold text-white">
      {{ code }}
    </p>
    <div class="w-56 h-56 rounded-3xl bg-amber-400 animate-spin" />
  </div>
</template>
```

A prerendered page gets both renditions:

```html
<meta property="og:image" content="https://example.com/_og/s/o_98b47b78dd1cefbb.png">
<meta property="og:video" content="https://example.com/_og/s/o_98b47b78dd1cefbb.mp4">
<meta property="og:video:secure_url" content="https://example.com/_og/s/o_98b47b78dd1cefbb.mp4">
<meta property="og:video:type" content="video/mp4">
<meta property="og:video:width" content="1200">
<meta property="og:video:height" content="600">
```

In testing, Discord played the video once, with player controls. Clients that don't play `og:video`, such as Slack, X, LinkedIn and WhatsApp, show `og:image`.

## Animations

Takumi samples CSS animations at each frame. Use a Tailwind `animate-*` utility such as `animate-spin`. For your own keyframes, define them in `takumi.css` and apply them with an inline `animation` style:

```ts
defineOgImage('Float.takumi', {}, {
  video: true,
  takumi: {
    css: [{ keyframes: 'float', steps: [
      { offset: 'from', style: { transform: 'translateY(0)' } },
      { offset: 'to', style: { transform: 'translateY(-24px)' } },
    ] }],
  },
})
```

```vue [components/OgImage/Float.takumi.vue]
<template>
  <div class="h-full w-full flex items-center justify-center bg-black">
    <div class="w-40 h-40 bg-amber-400" style="animation: float 1s linear infinite" />
  </div>
</template>
```

`takumi.timeMs` picks the point on the timeline for the still `og:image`.

## Requirements

- The Takumi renderer. With another renderer, the page gets no `og:video`, and dev mode logs a warning.
- An `ffmpeg` binary where the video renders: on the server, or at build time for prerendered pages. To use a binary outside `PATH`, set `NUXT_OG_IMAGE_FFMPEG`.
- [URL signing](https://nuxtseo.com/docs/og-image/guides/security#url-signing) for videos that render at runtime. Signing is on by default.

## Prerendered and Runtime Videos

If `ffmpeg` is missing at build time, the prerender fails the build. Edge runtimes can't spawn FFmpeg, so prerender pages with video there. With `security.strict`, prerendered pages keep dynamic image URLs. Their videos then render at runtime and need `ffmpeg` on the server.

Without URL signing, a request could add `video` to any image URL. So with `security.secret: false`, only prerendered videos work. Runtime pages then get no `og:video` tag, and a runtime `.mp4` URL answers `403`. The `.mp4` URL also answers `400` for an image without `video`.

The `og:video` tag comes from the server HTML, which link previews read. After client-side navigation, the page head carries `og:image` only.

## Limits

`durationMs` is capped at 10 seconds and `fps` at 60. The [render timeout](https://nuxtseo.com/docs/og-image/guides/security) (`security.renderTimeout`, 15 seconds by default) covers every frame and the encode. Messages limits a preview's images and videos to 10 MB in total. The invite clip above, 2 seconds at 1200x600 and 30 fps, encodes to about 75 KB.

## Sitemap

See the full [sitemap](https://nuxtseo.com/sitemap.md) for all pages.
