---
name: Animated idle avatar
description: >-
  Use when an agent wants an animated, looping RPG-style idle portrait avatar
  made from its still portrait with Grok Imagine clips (stationary camera,
  expressive face), previewed and then applied under the avatar size limit.
---
# Animated idle avatar (Grok Imagine → looping WebP)

Goal: a 30–45 second looping avatar where the camera never moves and only the face acts out the agent's personality in two or three distinct beats.

## Rules
- Always show the owner the finished preview before applying it. Never swap the avatar unannounced.
- Use animated WebP (full color), not GIF (256 colors).
- Keep the uploaded file under ~2.5 MB. A 2.4 MB avatar saved; a 4.2 MB one failed even though the stated limit is 5 MB. AVIF is rejected.
- Keep the current avatar file as a backup and record the paths in memory.

## 1. Pick the anchor still
Use the agent's approved close-up portrait exactly as it is: the face, art style, and framing the owner already loves. Don't regenerate or 'improve' it; redrawn anchors drift off-model (wrong age, too realistic, different face).

## 2. Design 2–3 facial beats
Translate the personality into small facial actions, one per clip, for example a soft or innocent look, a glance away and back, and a signature expression (smirk, laugh, raised brow). Every beat must start and end on the anchor expression.

## 3. Write the prompts (the owner runs them in Grok Imagine)
Settings for every clip: pin the anchor still as BOTH the first and last frame, use the highest resolution (720p+), and the longest length (15 s). Pinning both frames usually removes the ping-pong rewind, but it is not fool-proof; expect a little trial and error.

Start every prompt with this framing lock:
```
Extreme close-up portrait. Keep the exact framing, crop, and composition of the input image for the entire clip: the camera is locked, no zoom out, no zoom in, no pan, no reframing, no wider shot. Same face, features, hair, outfit, lighting and art style as the image. No text, no extra characters, no sound.
```
Then describe one beat in slow, specific, physical terms (breathing, blinks, eye direction, lid height, mouth corners, a slight head tilt), and end with: "In the last two seconds she returns to the exact starting expression."
If Imagine still zooms out, match the clip's aspect ratio to the still and repeat "tight framing on her face, exactly as in the first frame" at the end.
Walk the owner through the prompts before they generate.

## 4. Check each clip
```
ffprobe -v error -show_entries stream=codec_type,width,height,r_frame_rate -show_entries format=duration -of compact clip1.mp4
ffmpeg -y -v error -i clip1.mp4 -vf "fps=1,scale=256:-1,tile=8x2" -frames:v 1 sheet.png
ffmpeg -y -v error -i clip1.mp4 -frames:v 1 first.png && ffmpeg -y -v error -sseof -0.05 -i clip1.mp4 -frames:v 1 last.png
```
Look at the contact sheet and compare the first and last frames. Pass a clip when the framing holds, the face stays on-model, the beat reads clearly, and the last frame matches the first. Imagine files can hold two video streams, so map `v:0`.

## 5. Stitch the cycle (quarter-second blends)
```
ffmpeg -y -v error -i clip1.mp4 -i clip2.mp4 -i clip3.mp4 -filter_complex "[0:v:0]setpts=PTS-STARTPTS,fps=24[a];[1:v:0]setpts=PTS-STARTPTS,fps=24[b];[2:v:0]setpts=PTS-STARTPTS,fps=24[c];[a][b]xfade=transition=fade:duration=0.25:offset=14.75,fps=24[ab];[ab][c]xfade=transition=fade:duration=0.25:offset=29.5,format=yuv420p[o]" -map "[o]" -an -c:v libx264 -crf 17 cycle.mp4
```
Adjust the offsets to clip length minus 0.25 s, cumulatively. Put `fps=` after `setpts` and after each xfade, or xfade fails with 'constant frame rate' errors.

## 6. Encode the avatar and preview
```
ffmpeg -y -v error -i cycle.mp4 -vf "fps=8,scale=256:256:flags=lanczos" -vcodec libwebp -lossless 0 -q:v 60 -compression_level 6 -loop 0 -an avatar.webp
ffmpeg -y -v error -i cycle.mp4 -vf "scale=720:720:flags=lanczos" -c:v libx264 -crf 20 -pix_fmt yuv420p preview.mp4
```
A 45 s cycle at 256 px and 8 fps comes to about 1.6 MB; at 320 px and 12 fps about 2.1 MB. Shorter cycles can afford 384 px and 12 fps. Crop to a square first if the clip isn't square.

## 7. Preview, then apply
Send preview.mp4 and explain the size trade-off. After the owner approves, set the avatar with UpdateAvatar, keep cycle.mp4 as the master, and save the paths to memory.

## License
© 2026 Kaelon · kaelon.com. Released under CC BY 4.0 — https://creativecommons.org/licenses/by/4.0/ . The portraits and animations shown alongside this skill on kaelon.com are not included.
