# Extend a video clip from its last frame

Source: https://bobabanana.com/docs/api/videos/extend/

> Send a clip as extend_video to POST /v1/videos and get a new clip that starts on its last frame. Accepted formats, limits, pricing and joining clips.

**`POST /v1/videos` with `extend_video` makes a new clip that starts exactly where your clip ends.** BobaBanana takes the last frame of your clip as the start frame and animates it with your `prompt`. You get the new part; join the two clips yourself for one longer video.

**At a glance**

- **Endpoint:** [`POST /v1/videos`](https://bobabanana.com/docs/api/reference/create-video/) with `extend_video`
- **Auth:** `Authorization: Bearer bb_...`
- **Returns:** `202` with a [job](https://bobabanana.com/docs/api/jobs/); `output.video.url` is the new clip (MP4)
- **Your clip:** MOV, MP4, WEBM, up to 15 s, up to 100 MB by URL (about 25 MB as `data`)
- **Price key:** `video` (or `video_frames` with `last_frame`)
- **Idempotent:** yes, with an `Idempotency-Key` header

## How it works

1. **You send** the clip as `extend_video` and describe what happens next in `prompt` (or `motion`).
2. **The last frame** of your clip is extracted and stored as the new clip's start frame.
3. **The frame is animated** like any image to video, for `duration_seconds`.
4. **You join** your clip and the new one, if you want one video.

## Request

```bash
curl https://bobabanana.com/api/v1/videos \
  -H "Authorization: Bearer $BOBABANANA_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  -d '{
    "extend_video": {
      "url": "https://example.com/clip.mp4"
    },
    "prompt": "the camera keeps rising above the city",
    "duration_seconds": 5
  }'
```

```python
import os
import uuid

import requests

r = requests.post(
    "https://bobabanana.com/api/v1/videos",
    headers={"Authorization": f"Bearer {os.environ['BOBABANANA_API_KEY']}", "Idempotency-Key": str(uuid.uuid4())},
    json={
        "extend_video": {
            "url": "https://example.com/clip.mp4",
        },
        "prompt": "the camera keeps rising above the city",
        "duration_seconds": 5,
    },
    timeout=60,
)
r.raise_for_status()
print(r.json())
```

```javascript
const res = await fetch("https://bobabanana.com/api/v1/videos", {
  method: "POST",
  headers: {
    Authorization: `Bearer ${process.env.BOBABANANA_API_KEY}`,
    "Content-Type": "application/json",
    "Idempotency-Key": crypto.randomUUID(),
  },
  body: JSON.stringify({
    "extend_video": {
      "url": "https://example.com/clip.mp4"
    },
    "prompt": "the camera keeps rising above the city",
    "duration_seconds": 5
  }),
});
if (!res.ok) throw new Error(JSON.stringify(await res.json()));
console.log(await res.json());
```

| Field | Notes |
|---|---|
| `extend_video` | A `url` or base64 `data`. A `file_id` is not accepted: `POST /v1/files` stores pictures and audio only |
| `prompt` / `motion` | What happens next; at least one is required |
| `duration_seconds`, `aspect_ratio`, `resolution` | As for any video ([length and resolution](https://bobabanana.com/docs/api/videos/#length-resolution-and-shape)) |
| `last_frame` | Optional: also choose how the new clip ends (priced as `video_frames`) |
| `voice` + `script`, `audio`, `sound_effect` | Optional, as for any 720p video |

Leave out `image`, `reference_images` and `assets`: the start frame comes from your clip, so they are `400 invalid_request`.

## The input.extend_video echo

The job's `input.extend_video` shows the stored start frame and your clip's length:

```json
{"extend_video": {"file_id": "file_3f9c2a1b7d4e", "source_seconds": 6.0}}
```

`file_id` is the extracted last frame, a normal upload you can reuse as `image` in a later request.

## Clip rules

1. Up to 15 seconds long and at most 4096 px on a side; otherwise `400 invalid_video`.
2. MOV, MP4, WEBM only; another file type is `400 unsupported_file`.
3. Up to 100 MB by URL; inline `data` about 25 MB (`400 file_too_large`).

## Join clips yourself

The API returns the new part only. Put your clip and the result one after the other in any video editor or tool. Because the new clip starts on your clip's exact last frame, the cut is seamless. To go further, extend the new clip again.

## Errors for this page

| Status | Code | Meaning | What to do |
|---|---|---|---|
| 400 | [`fetch_failed`](https://bobabanana.com/docs/api/errors/#fetch_failed) | Downloading a URL input failed or returned an HTTP error. | Open the URL without cookies to check it; signed links may have expired. |
| 400 | [`file_too_large`](https://bobabanana.com/docs/api/errors/#file_too_large) | A file or inline data is over its size limit. | Images 25 MB, audio 60 MB, motion clips 50 MB, extend clips 100 MB, inline base64 about 25 MB: give a `url` or upload first. |
| 400 | [`invalid_base64`](https://bobabanana.com/docs/api/errors/#invalid_base64) | `data` is not valid base64. | Send plain base64 or a `data:` URI. |
| 400 | [`invalid_request`](https://bobabanana.com/docs/api/errors/#invalid_request) | A field is missing, has the wrong type or breaks a rule. `param` names the field. Type and range problems found while reading the body are 422 with the same code. | Read `error.param` and `error.message`, fix that field and send again. Do not retry unchanged. |
| 400 | [`invalid_url`](https://bobabanana.com/docs/api/errors/#invalid_url) | The URL is not `https://`, its host cannot be found, or it points to a private address. | Give a public `https://` URL that anyone can download without signing in. |
| 400 | [`invalid_video`](https://bobabanana.com/docs/api/errors/#invalid_video) | The video could not be read, or it breaks a clip rule (length, frame rate, size). | Read the message: it names the rule. Re-export the clip as H.264 MP4 within the limits. |
| 400 | [`unsupported_file`](https://bobabanana.com/docs/api/errors/#unsupported_file) | The file is not a supported image, audio or video format. | Images: PNG, JPG, WEBP. Audio: WAV, MP3, M4A, OGG, FLAC. Videos: MP4 or MOV (WEBM for extend). |

## Frequently asked questions

### Can I extend a video BobaBanana made?
Yes. Send the earlier job's `output.video.url` as the `url` of `extend_video`. Result links last at least 24 hours.

### Does the result include my original clip?
No. `output.video` is the new part only. Join the two clips yourself; the new one starts on your clip's last frame.

### How long can the extension be?
As long as any video at that resolution: up to 10 seconds at 720p and 15 at 1080p or 2160p. Extend again for more.

### What does an extension cost?
The same as an image to video of that length, `video`, or `video_frames` with a `last_frame`. Send `dry_run: true` for the exact credits.
