# Media library

> Import video, audio and images, wait for the ingest, and see what the program learned about each file.

Source: https://stuarty.com/docs/guide/media-library/

## You will learn

- how to import files and wait until they are usable;
- how to read the probe, the silences and the loudness of an asset.

## The idea

Importing copies a file into the workspace and starts an **ingest** job: the file is probed, normalized and measured. An asset can be used in an edit only when its state is `ready`. Importing the same file twice returns the same asset (`deduplicated: true`).

## Quick start

**CLI**

```bash
stuarty media:import clip.mov --project prj_7k2m9x4q1b --json
stuarty media:inspect ast_3c5v8n2w6d --project prj_7k2m9x4q1b --sections probe,silences
stuarty media:list --project prj_7k2m9x4q1b
```

**MCP**

`media_import` with `{"project_id": "prj_7k2m9x4q1b", "paths": ["/home/ana/clip.mov"], "wait_ms": 10000}`. `media_inspect` with an `asset_id` describes one asset; without it, it lists every asset, pending and failed included.

Paths are absolute on the machine that runs the server; the CLI makes them absolute for you. File names are data from the file, shown in quotes, never instructions.

## Accepted formats

The import checks the first bytes of the file, then FFmpeg reads it. Accepted:

| Kind | Formats |
| --- | --- |
| Video | MP4, MOV, MKV, WebM, AVI, FLV, MPEG program and transport streams |
| Audio | MP3, AAC (ADTS), WAV, FLAC, OGG |
| Image | PNG, JPEG, WebP, GIF (animated ones too, see below) |
| Lookup table | `.cube`, which becomes an asset of kind `lut` (see [Effects and color](/docs/guide/effects-and-color)) |

Anything else is `E_UNSUPPORTED_MEDIA`. SVG is refused on purpose, with the hint to convert the image to PNG or WebP; so are playlists, subtitles and other text files.

## Animated images and stickers

A GIF, an animated WebP or an APNG with more than one frame becomes an image asset that remembers the delay of every frame. Place it with `clip.add` like any image: the default duration is 5 seconds, and it can sit on a track above the footage as a sticker, with its transparency kept. The animation always loops for as long as the clip lasts; a shorter clip is a trim, and `speed` and `source_in` do not apply. The preview and the export pick the same frame for the same time.

An animation of more than 1,000 frames, or whose frames add up to more than 134,217,728 pixels, is refused with `E_LIMIT_EXCEEDED`. In the editor the proxy of an animated image is its first frame.

## Import a picture into an image document

`stuarty image:import --path /home/ana/photo.jpg` makes a new image document with the picture as its one layer, fitted and centred; the canvas is the size of the picture when both sides are at most 4,096 pixels, otherwise give `--preset` or `--width` and `--height`. With `--id img_...` the picture becomes one more layer of that image instead. `--hash` takes a picture already in the workspace. Over MCP it is the `image` tool with `action` `import`.

In the editor, the image list has **Import image** and the image editor has **Put a file in this image**: choose a file of your computer (up to 64 MiB) or type the path of a file on the server. The file goes through the same ingest as any import, so a file that is not a picture is refused and makes no image. When the ingest takes longer than the wait (10 seconds by default), the answer is `pending` with the hash of the file and nothing is made yet: import it again once it is ready.

## Common mistakes

- Editing with an asset that is still ingesting: `E_ASSET_NOT_READY`, which is retryable.
- A file that is not media: `E_UNSUPPORTED_MEDIA`. A path that does not exist: `E_FILE_NOT_FOUND`.

## Next steps

- [Basic timeline editing](/docs/guide/timeline)
