Media and scene management
Media and scene management gives the editor a project-scoped set of source assets and useful ways to find parts of those assets. It accepts local files, direct media URLs, generated assets, and Lottie animations. It then records metadata, prepares previews and analysis data, and exposes the results to the timeline, source preview, and other editing tools.
Media library
Asset workspace
The media library is the editor's asset workspace. It groups video, audio, images, GIFs, and Lottie assets so an engineer or user can find the source material for an edit. Search matches file names and available AI captions, while type filters, sort choices, and grid or list views change how the same project assets are presented. The workspace can switch between the media library and the Scene Browser without leaving the editor. See Editor workspace for the larger workspace that hosts this library.
The library also includes compositions as editable assets. Selection is shared with actions such as deletion and proxy generation, and a media item can be dragged into an editing surface to create a timeline relationship. Background work stays visible in the library so users can track media preparation, analysis, transcripts, proxies, and other derived assets while they continue to browse.
References: src/…/media-library.tsx• L235-341 src/…/media-library.tsx• L956-1023 src/…/media-library.tsx• L1268-1480 src/…/media-grid.tsx• L223-309 src/…/media-library-store.ts• L101-121
Project asset scope
Media is available through the active project rather than as one global list. A project keeps associations to media records, so the editor can reuse a source across projects without losing project-level isolation. When the library loads, it also repairs old or incomplete associations that are still required by timeline content and removes links to media records that no longer exist.
This boundary lets editing workflows use stable media IDs while storage can keep source bytes in a durable workspace, retain links to a user's original files, or read older stored records during migration. Media URL resolution also shares in-flight work for the same source, then clears that bookkeeping when a project route is cleaned up so a later request can start fresh.
References: src/…/project-media.ts• L1-13 src/…/project-media.ts• L212-307 src/…/media-resolver-requests.ts• L1-19 src/…/index.tsx• L1-15 src/…/storage.ts• L1-16
Media import and preparation
Import sources
The import flow turns a user-selected or downloaded file into a project media asset. Users can copy a local file into the workspace for durable access, link to the original file for a local-first workflow, or provide a direct HTTP(S) media URL that the browser can download. Drag-and-drop uses the same import contract as the file picker.
The flow checks that the input is a real supported media file. It avoids adding a second visible copy when the project already contains the same source, while still allowing an existing workspace asset to be associated with a new project.
References: src/…/media-library.tsx• L398-448 src/…/media-library.tsx• L639-699 src/…/media-import-actions.ts• L287-421 src/…/media-library-service.ts• L889-1011
Asset metadata and previews
After import, the system makes an asset useful before an edit begins by recording its type, size, duration, dimensions, frame rate, codec information, and thumbnail. A short preparation state can remain visible while these results and related caches become ready. Video, audio, image, GIF, and Lottie inputs follow the same library contract while receiving the preparation suited to their content.
The library keeps source access separate from derived data. Thumbnails, filmstrips, waveforms, decoded audio, and proxies can be rebuilt or removed without changing the identity of the source asset. Unsupported audio or video codecs are surfaced as limits on preview or waveform use instead of silently presenting incomplete media. Longer preparation and enhancement work reports progress in the library, with cancellation where the related workflow supports it.
References: src/…/media-library.tsx• L1268-1480 src/…/media-library-service.ts• L229-237 src/…/media-library-service.ts• L585-725 src/…/media-preparation-store.ts• L3-27 src/…/storage.ts• L38-119
Asset health and removal
The library checks whether each source can still be read. This matters most for linked files because a user can move the file or revoke access after import. Broken assets are marked for review and can be relinked; timeline clips that point to removed media are treated as orphaned clips so the user can repair or remove them.
The relink flow updates the stored source handle and invalidates stale preview data. It also clears cached source and conform data for timeline items that use the repaired asset, so those items resolve the new source. For an orphaned clip, relinking updates the clip's media identity and source facts, clears cached URLs and waveform data, and applies the change to synchronized linked clips when needed.
Removing an asset first removes its relationship to the current project. The library warns when timeline items refer to the selected asset and removes those project items before it deletes the media record. A linked source remains on the user's disk, while workspace-managed source data is reclaimed only when it is no longer needed.
References: src/…/media-grid.tsx• L135-169 src/…/media-grid.tsx• L176-220 src/…/media-relinking-actions.ts• L23-55 src/…/media-relinking-actions.ts• L57-126 src/…/media-relinking-actions.ts• L191-243 src/…/media-relinking-actions.ts• L254-335 src/…/types.ts• L32-54 src/…/types.ts• L200-225 src/…/media-library-service.ts• L1479-1502 src/…/media-library-service.ts• L526-545
Scene analysis and browsing
Scene analysis
Scene analysis converts video and image assets into timestamped scene records that are easier to search than raw files. The analysis can produce captions, representative thumbnails, dominant color palettes, and text or image embeddings. Embeddings are numeric descriptions that support meaning-based and visual matching rather than only exact words.
Analysis can run for one asset, for assets without captions, or for all eligible assets. It runs locally, stores results with the media, and reuses content-matched results when the same source has already been analyzed. A new run replaces stale scene outputs so the browser does not mix old and new results.
References: src/…/media-analysis-service.ts• L1-9 src/…/media-analysis-service.ts• L60-163 src/…/media-analysis-service.ts• L166-337 src/…/scene-detection.ts• L1-20
Scene search
The Scene Browser presents each analyzed scene as a searchable moment in source media. Keyword search matches caption text. Semantic search matches meaning, and color search compares palettes. A user can search the full project or limit results to one captioned asset, then sort by relevance, time, or media name and use list or grid view.
The browser keeps the search result tied to the source asset and timestamp. Selecting a result seeks the source preview to that moment. A scene can also be dragged to the timeline, where the editing workflow can place that source moment into the composition. The media library exposes this browser as a separate view so media search controls do not conflict with scene search controls.
References: src/…/scene-browser-panel.tsx• L53-141 src/…/scene-browser-panel.tsx• L147-250 src/…/media-library.tsx• L956-1023 src/…/media-library.tsx• L1184-1201 src/…/scene-browser-store.ts• L16-72 src/…/scene-card.tsx• L50-100
Scene result ranking
Scene ranking joins media metadata with its caption records so each result carries a file name, time, text, thumbnail, and palette. The active search mode decides which signal leads the ranking. A palette selected from a scene can become a new visual reference, which makes the browser useful for finding related shots as well as named subjects.
Only analyzed media contributes scene results. During re-analysis, old scenes are hidden for the affected asset and the browser shows that new results are being prepared. If a semantic model is still loading, keyword results remain available as a useful fallback.
References: src/…/use-ranked-scenes.ts• L61-73 src/…/use-ranked-scenes.ts• L155-247 src/…/scene-card.tsx• L72-83
Lottie asset management
Lottie asset discovery
Lottie is a vector animation asset type that the media library treats as a first-class editing source. The Lottie browser reads public LottieFiles feeds for featured, popular, and recent animations, or searches the provider when a query is present. Results provide a preview, title, creator information, and an import action.
The browser loads one page at a time and keeps the current result set visible while a new page or search is loading. It marks an animation as importing, imported, or failed so a user can retry a failed download without confusing it with an animation already in the library.
References: src/…/lottie-browser-panel.tsx• L12-87 src/…/lottie-browser-panel.tsx• L134-218 src/…/lottie-browser-store.ts• L20-52 src/…/lottiefiles-api.ts• L19-41
Lottie import and attribution
Importing a Lottie result downloads the animation into the project media library and gives it a readable file name. The import records provider, creator, source identifier, and license data so later workflows can preserve asset credit and usage terms. The same import path also accepts local .json or .lottie files.
Lottie metadata supplies the animation size, frame rate, and duration. The system creates a representative thumbnail because a Lottie file is an animation description rather than a normal raster image. This makes it visible beside other media without changing the original animation data.
References: src/…/lottie-browser-store.ts• L132-170 src/…/lottiefiles-api.ts• L173-185 src/…/media-library-service.ts• L339-390 src/…/media-library-service.ts• L1230-1271
Lottie editing handoff
Once imported, a Lottie asset enters the same media-to-timeline path as other assets. The selected timeline item can resolve a fresh media URL after a reload, then expose the animation's bundled animations, themes, markers, text layers, color layers, and value slots when those features exist.
The Lottie inspectors accept either parsed animation data or raw JSON and ignore input that cannot be parsed. Shared normalization keeps text, color, and numeric-slot discovery on the same input contract. These discovered parts support focused editing of speed, direction, looping, segments, text, colors, and named values. The resulting overrides belong to the timeline item, so the source asset remains reusable while preview and export can apply the same choices.
References: src/…/lottie-section.tsx• L99-105 src/…/lottie-section.tsx• L131-194 src/…/lottie-section.tsx• L221-274 src/…/lottie-json.ts• L1-16 src/…/lottie-text.ts• L119-180 src/…/lottie-color.ts• L288-335 src/…/lottie-slots.ts• L69-91 src/…/lottie-browser-contract.ts• L1-6
Editing workflow connections
Timeline placement
Media cards and scene results are entry points into timeline editing. A media drag carries the asset identity and basic source facts. A scene drag carries the asset identity, file name, and source time so the timeline can place the requested moment instead of treating the scene as a separate file.
The source preview uses the same media identity and time when a user opens a card or scene. This keeps browsing, preview, and timeline placement aligned even when a project has several clips from one source.
References: src/…/media-card.tsx• L1235-1281 src/…/scene-card.tsx• L86-100 src/…/scene-row.tsx• L91-105 src/…/scene-card.tsx• L50-53
Derived media workflows
The media library is also the handoff point for derived assets that editing needs. Proxies help preview difficult or heavy video. Waveforms and transcripts support audio editing and caption work. Frame interpolation and upscaling create new library items rather than changing the source item, which preserves the original for other edits.
These services report status through the media library so users can see work in progress and choose the resulting asset when it becomes available. See Timeline editing for placement and clip behavior, Effects and animation for visual controls, and Preview and export for render use.
References: src/…/media-card.tsx• L455-508 src/…/media-library.tsx• L1307-1480 src/…/media-library-store.ts• L139-161 src/…/media-library-store.ts• L680-714
Change checklist
When these files or sections are changed, remember to consider these:
- Keep the media storage modes aligned with source resolution and cleanup rules in
MediaMetadata, the project association layer, and the media service. - Keep import duplicate handling aligned between local files, URL files, and remote Lottie assets so the library and placement flows receive the same asset result.
- Keep media URL request sharing and project-route cleanup aligned so stale in-flight work cannot block later source resolution.
- Keep scene caption, thumbnail, palette, and embedding updates consistent with the content-cache identity and with the Scene Browser ranking inputs.
- Keep scene drag data compatible with timeline drop handling when scene IDs or source timestamps change.
- Keep Lottie attribution fields and file naming aligned with the provider browser and the media record used by the editor.
- Keep Lottie JSON input normalization aligned across text, color, and numeric-slot inspectors.
- Keep Lottie metadata discovery aligned with the timeline item's selected animation, segment, and override fields.
- Keep the media library's media/scene view switch aligned with each view's search, filter, selection, and drag behavior.
- Keep background task status and cancellation actions aligned with the derived-asset services that publish those states.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| The active project is missing during import. | The file is not associated with a project and is not returned to the editing workflow. | Require a current project before file, URL, or Lottie import. |
| A linked source file is moved or its permission expires. | Thumbnails, preview, analysis, or timeline playback cannot read the source. | Scan media health and use the relink flow for the broken asset. |
| A URL returns a web page or blocks browser-side download. | No media record is created from the URL. | Use a direct CORS-enabled media file URL rather than a watch page. |
| A media resolution request remains in flight during project cleanup. | A later request can join stale bookkeeping instead of resolving the source again. | Clear pending media requests when the project route is cleaned up. |
| Scene analysis has not produced captions. | The Scene Browser has no searchable scenes for that asset. | Run analysis for new media or re-analyze the selected asset. |
| Semantic or visual model loading fails. | Meaning or visual ranking is unavailable, but exact caption search can still work. | Fall back to keyword ranking and show model/index progress. |
| A Lottie provider request fails or returns no animation file. | The animation cannot be added to the media library. | Keep the item retryable and surface the provider or download error. |
| Lottie input is malformed or has no supported layers. | Text, color, or value controls show no editable entries. | Treat invalid input as empty inspector data and keep the source unchanged. |
| A media asset is deleted while timeline clips still reference it. | The timeline contains orphaned clips that cannot resolve their source. | Warn about affected clips and offer orphaned-clip relink or removal. |
Key files
| File | Why to read it |
|---|---|
| src/…/media-library.tsx | Shows the user-facing asset workspace, import entry points, media/scene switch, filters, and background task status. |
| src/…/media-grid.tsx | Shows selection, source preview opening, deletion warnings, timeline reference removal, and broken-file relinking. |
| src/…/media-library-store.ts | Shows project-scoped library state, loading, selection, health, and derived-work status. |
| src/…/media-import-actions.ts | Shows how picker, drag-drop, URL, and remote Lottie imports reach one library contract. |
| src/…/media-relinking-actions.ts | Shows how repaired sources and orphaned timeline clips regain valid media links. |
| src/…/media-library-service.ts | Shows the asset lifecycle from source validation through metadata, thumbnails, persistence, and cleanup. |
| src/…/media-resolver-requests.ts | Shows the shared bookkeeping that prevents duplicate source-resolution requests and supports cleanup. |
| src/…/project-media.ts | Shows how project-to-media relationships make assets available to the active edit. |
| src/…/media-analysis-service.ts | Shows the high-level analysis path that creates captions and search data. |
| src/…/scene-browser-panel.tsx | Shows scene analysis controls, scope, sorting, views, and result presentation. |
| src/…/use-ranked-scenes.ts | Shows how media captions and search signals become ranked scene results. |
| src/…/lottie-browser-panel.tsx | Shows provider browsing, search, paging, import state, and attribution notice. |
| src/…/lottiefiles-api.ts | Shows the provider-facing animation data and attribution contract. |
| src/…/lottie-json.ts | Shows the shared input boundary for Lottie inspectors. |
| src/…/lottie-section.tsx | Shows how an imported Lottie becomes an editable timeline asset. |