# Video creatives

This note describes the video creative work that is already built. It is for this release only.

An advertiser can create a Video creative in two ways:

- Upload one MP4 file.
- Enter a VAST web address.

The creative is saved as a draft. It is not sent for review. It cannot be attached to a line item. Video delivery is not available until early 2027.

Image creatives and text creatives are unchanged.

## Flow

```text
Advertiser
    |
    v
Upload one MP4, or enter a VAST https address
    |
    v
Browser checks the MP4 before upload
    |
    v
API confirms the file is a real MP4
    |
    v
API checks length, picture size, H.264, sound, and frame rate
    |
    v
Store the file
    |
    v
Save the creative as a draft
    |
    v
Form and library show the length
```

VAST skips the file steps. The server only checks and stores the address.

## Step 1. The advertiser starts a video creative

On the create-creative page they pick Video, then one of these:

- MP4. This is the default. They upload one file.
- VAST. They enter a web address that starts with `https://`.

The page tells them:

> Video isn't available yet. You can create and save video creatives now. They stay as drafts until video is available in early 2027. Drafts can't be reviewed or added to a line item yet.

Switching between MP4 and VAST asks for confirmation, then clears the other one.

## Step 2. The browser checks an MP4 first

This happens before the file is sent.

| Check        | Rule                |
| ------------ | ------------------- |
| File kind    | MP4                 |
| Size         | Up to 200 MB        |
| Length       | 5 to 60 seconds     |
| Picture size | At least 1280 × 720 |
| Shape        | 16:9                |

If it fails, the page shows the reason and does not upload.

While the file is uploading, the page shows a progress bar and how far it has got, for example:

```text
Uploading… 42% (84 of 200 MB). Keep this page open.
```

Before the file is sent, the same page says `Checking the video…`. The person can press Cancel. Cancel stops that upload and frees the slot. If the connection drops, or the person closes the page, the upload does not continue from the middle. They pick the file and start again.

## One video at a time for the same person

Each signed-in person can have one MP4 upload in progress. The page blocks a second file on that same page. The API blocks a second file that comes from another tab, another browser, or another device while the first upload is still going.

The message in every one of those cases is:

```text
You already have a video uploading. Wait for it to finish, or cancel it.
```

The slot belongs to the signed-in person, not to the whole site. A different person can upload a video at the same time. An image upload does not take this slot. A VAST address does not take this slot, because no file is sent.

The API keeps the slot in the memory of the one API process. It is taken after the API has read enough of the file to see that it is an MP4. It stays taken while the file is received, checked, and stored. It is released when that request finishes: the upload is saved, a check fails, the connection is cut, or Cancel has stopped the request. If the API process restarts, the slot is cleared and the unfinished file is not saved.

The progress line is shown only on the browser that is uploading. The other browser does not see the percentage. It sees the message above.

### How to check these cases

Use one signed-in person and one MP4 that passes the checks in the table above. Keep the first page open until the case says otherwise.

| What you do                                                                                                          | What should happen                                                                                                                                                           |
| -------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Start one MP4 upload and watch that page                                                                             | The row changes from `Checking the video…` to `Uploading…` with a percent, the amount sent, the file size, and `Keep this page open.` A progress bar moves with the percent. |
| On that same page, try to pick a second MP4 before the first finishes                                                | The first upload keeps going. The page shows `You already have a video uploading. Wait for it to finish, or cancel it.` The second file is not sent.                         |
| Open the create page in a second tab, signed in as the same person, and upload another MP4                           | The second tab shows the same sentence. Its file is not saved. The first tab keeps its progress.                                                                             |
| Open another browser, or another device, sign in as the same person, and upload another MP4                          | Same result as the second tab. The API sees the same person and refuses the second upload.                                                                                   |
| Press Cancel on the first page, then upload from the other browser                                                   | The first upload stops. The other browser can upload.                                                                                                                        |
| Wait until the first upload finishes or fails, then upload from the other browser                                    | The other browser can upload. A failed check also frees the slot.                                                                                                            |
| Close the first page, or disconnect it, while it is uploading                                                        | That upload stops and does not resume from the middle. After the server sees the connection is gone, the same person can start a new upload from the beginning.              |
| Sign in as a different person in another browser and upload an MP4 while the first person is still uploading         | Both uploads are allowed. The limit is one video per person, not one video for the whole site.                                                                               |
| Upload a JPG, PNG, or GIF while your own MP4 is still uploading                                                      | The image upload is allowed. Only MP4 uploads take the slot.                                                                                                                 |
| Save a VAST address while an MP4 upload is in progress                                                               | VAST does not send a file, so it does not take the slot.                                                                                                                     |
| Sign in as an admin and start an MP4 for an advertiser, then start another MP4 as that same admin in another browser | The second one is refused. The slot follows the admin who is signed in. A different admin can upload at the same time.                                                       |

## Step 3. The API checks the real file

The file name and the file extension are not trusted. The API reads the file itself.

The upload is `POST /assets/upload`. The file is written to a temporary file on the server, such as:

```text
/tmp/creative-upload-<id>.bin
```

The API process does not keep the whole video in memory.

Then it checks:

| Check            | Rule                                                |
| ---------------- | --------------------------------------------------- |
| It is a real MP4 | Yes. The `file-type` package reads the file header. |
| Length           | 5 to 60 seconds                                     |
| Picture size     | At least 1280 × 720, and 16:9                       |
| Picture format   | H.264                                               |
| Sound            | AAC, or no sound                                    |
| Frame rate       | Up to 30 frames per second                          |

A 1280 × 720 video is allowed. The check is not limited to 1920 × 1080.

The API does this with its own MP4 reader. It does not use FFmpeg.

## Step 4. The file is stored

The file is stored only when step 3 passes. The creative row is written after that, by `POST /creatives`. A failed MP4 check or a failed VAST address check does not write the row. The stored name looks like:

```text
video-creatives/<uuid>.mp4
```

It is saved on the server disk, or in S3 when S3 is configured. The temporary file is then deleted.

New uploads use the same relative keys on both storage backends:

| Upload                         | Local folder / S3 prefix        |
| ------------------------------ | ------------------------------- |
| Creative image (JPG, PNG, GIF) | `image-creatives/`              |
| Creative video (MP4)           | `video-creatives/`              |
| Advertiser identity document   | `advertiser-identity-document/` |

Local files are placed under `ASSET_STORAGE_DIR` (default: `.data/storage`).
S3 objects use these prefixes inside the configured bucket. Files keep UUID-based names.
Existing files and database keys are not moved or rewritten; older keys remain readable.

If a check fails, nothing is stored. The reason stays on the upload row.

## Step 5. The creative is saved as a draft

Saving uses `POST /creatives`.

For an MP4, the API reads the stored file again and saves the length it finds there.

| Saved field    | Value                                 |
| -------------- | ------------------------------------- |
| Status         | Draft                                 |
| Length         | From the file, for example 15 seconds |
| Picture format | H.264                                 |
| Sound format   | AAC, or empty when there is no sound  |

For VAST, the API stores the `https` address on the creative. The address can be up to 2048 characters. There is no video file. The server does not open or download that address.

Image and text creatives still save as Active and still go through approval.

## Step 6. What the advertiser sees

After a successful MP4 upload, the form shows a line like:

```text
clip.mp4 · 1920 × 1080 · 0:15 · H.264 · AAC · 12.4 MB · Uploaded
```

A video with no sound says `No sound` instead of `AAC`. A player appears only after the server accepts the file.

The library Dimensions column shows:

```text
1920 × 1080 · 0:15
```

A VAST creative shows `VAST`.

A draft is not sent for review and cannot be attached to a line item. The same notice from step 1 is shown on the creative detail page.

| Line item | What can be attached    |
| --------- | ----------------------- |
| Display   | A display creative      |
| Text      | A text creative         |
| Video     | Nothing in this release |

A display creative attached to a video line item is refused. The API says `Display creatives can only be attached to a display line item.` A video creative attached to any line item is refused with `Video creatives cannot be attached to a line item yet`. On a video line item, the add-creative window does not offer a creative to attach, and Create new stays disabled.

## What this release does not do

These were left out on purpose:

- An admin review screen
- Sending the video for approval
- Attaching the video to a line item
- Playing the video as an ad
- Downloading or reading the VAST file
- A malware scan of the uploaded video

## Checklist

| Check                                                                              | In this release |
| ---------------------------------------------------------------------------------- | --------------- |
| One real MP4, or one VAST https address                                            | Yes             |
| Length 5–60 seconds                                                                | Yes             |
| At least 1280 × 720, 16:9                                                          | Yes             |
| H.264 picture                                                                      | Yes             |
| AAC sound, or no sound                                                             | Yes             |
| Frame rate up to 30                                                                | Yes             |
| Saved as a draft                                                                   | Yes             |
| Length shown on the form and in the library                                        | Yes             |
| Progress percent and bar while the MP4 uploads                                     | Yes             |
| One MP4 upload at a time for the same signed-in person, including a second browser | Yes             |
| A different person can upload a video at the same time                             | Yes             |
| Sent for review                                                                    | No              |
| Video creative attached to a line item                                             | No              |
| Display creative attached to a video line item                                     | No              |
| Display creative attached to a display line item                                   | Yes             |
| VAST file downloaded                                                               | No              |
| Existing image and text creatives changed                                          | No              |
