Skip to content

feat: use a picture instead of a webcam - #4465

Open
richiemcilroy wants to merge 6 commits into
improve/camera-toolbar-hintsfrom
feat/camera-picture
Open

richiemcilroy wants to merge 6 commits into
improve/camera-toolbar-hintsfrom
feat/camera-picture

Conversation

@richiemcilroy

@richiemcilroy richiemcilroy commented Nov 23, 2026 •

Copy link
Copy Markdown
Member

Use a picture instead of a webcam. Pick it from the camera menu or straight from the camera bubble, record with it, or add one in the editor to a recording made without a camera.

Stacked on #4462 (camera toolbar hints), which gives the new bubble buttons their hints.

Switch from the bubble

Camera, then Use a picture, then Change picture / Use your camera:

  • The picture button uses the last picture, or asks for one the first time.
  • "Use your camera" goes back to the camera the picture replaced.
  • These buttons hide while recording and in the picker's Camera Only view, which needs a real camera.
  • With six buttons the toolbar now fits to the bubble's width (blur, then mirror, then picture give way first).

Camera menu

Before a picture is chosen With a picture

The same choice is in the recording picker's camera menu. The picture replaces the camera (and the other way round), the pill reads On, and no camera permission is needed.

Recording with it

A real 5 s Studio recording with the picture and no camera device. The project has only display.mp4, no camera track, and cameraPicture set:

Exported frame:

A recording made without a camera (on main the Camera tab is disabled for these):

How it works

flowchart LR
  pick[Menu or bubble picks a file] --> norm["camera_picture::normalize<br/>upright, opaque, ≤1024 px, JPEG"]
  norm --> feeds["Feeds.camera_picture"]
  feeds --> bubble[Bubble draws the still]
  feeds --> studio["Studio: copied to<br/>content/images/camera-picture.jpg"]
  studio --> config["project-config.json<br/>cameraPicture"]
  editor[Editor: Add picture] --> config
  config --> render["cap-rendering:<br/>picture fills the camera slot"]
Loading
  • Normalized once (apps/desktop-gpui/src/camera_picture.rs): EXIF orientation applied, transparency flattened onto white, scaled to at most 1024 px, saved as JPEG. Nothing heavy happens while recording.
  • Studio records no camera track. The picture is copied into the project once the recording is running, and finalize writes cameraPicture with the bubble's shape and position, blur off.
  • Instant (macOS, Windows) records the bubble on screen, exactly as it does a camera, so a window capture keeps the screen region. Linux Instant draws the camera from its live feed and cannot draw a still yet, so starting one with a picture says to use Studio instead of dropping the picture silently.
  • Renderer (crates/rendering/src/camera_picture.rs): RenderVideoConstants::camera_picture decodes the file once and hands the camera layer one shared frame, so the layer's storage-identity check uploads it to the GPU once. It applies only when the recording has no camera track, and the per-frame background blur is skipped for it. Editor preview, export and every other cap-rendering caller get it with no decoder changes.
  • Project field ProjectConfiguration::camera_picture sits outside camera, so presets and style segments (which copy camera whole) never carry one project's picture into another.
  • Full shape keeps the picture's own aspect in the bubble, the one the editor's Source shape draws, so the bubble shows what gets recorded.

All new strings are translated in every catalog.

RetriggerView in GreptileConfidence Score: 2/5

Fix picture preservation and project path checks before merging, and satisfy the repository's comments policy.

Findings

  1. P1 Presets remove the picture ▶
  2. P1 Security Projects can read outside images ▶
  3. P2 Linux loses the picture position ▶
  4. P2 Comments repeat the code ▶
Fix with agent prompt
### Issue 1
crates/project/src/configuration.rs:3229-3234
`preset_config` saves `camera_picture`, but `with_preset` does not preserve the current project's value. Applying an older or built-in preset therefore removes the chosen picture. A default preset also removes the picture that `finalize_studio` just saved.

Exclude `cameraPicture` from saved presets and preserve the current project's value when applying them.

### Issue 2
crates/rendering/src/camera_picture.rs:38-39
`relative` comes from the saved `cameraPicture` field, but this join accepts absolute paths and `..`. A crafted project without a camera track can make the renderer read an image outside the project and include it in exported frames.

Reject paths that resolve outside the project, including links that point outside it.

**How this was verified:** Opening a project loads `cameraPicture` without a path check, and the export passes it to this loader and then to the camera layer.

### Issue 3
apps/desktop-gpui/src/camera_window.rs:1983-1987
Picture-only Studio recordings cannot save the bubble's position on Linux. `studio_snapshot` gets Linux bounds through `recording_snapshot`, which requires `frame_dims` from a delivered camera frame. A picture supplies no such frame, so no placement is saved and the editor falls back to its camera position.

Use the picture dimensions when taking this snapshot.

### Issue 4
apps/desktop-gpui/src/camera_picture.rs:145-146
These descriptions repeat the function names and visible code. `AGENTS.md` requires comments to explain non-obvious context and explicitly bans narrating what code does. The same pattern appears above `select_or_choose` and `load`.

Remove these descriptions or keep only the parts that explain a real constraint. This repository requirement must be satisfied before merging.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Summary

Adds still pictures as an alternative to a webcam.

  • The camera menu and bubble can switch between a picture and a camera.
  • Studio recordings keep the picture for the editor to show later.
  • The editor can add or remove a picture where a camera would be.
  • Preview and export draw the project picture in the camera layer.
  • Module ordering and a few test lines are reformatted without changing behavior.

Reviews (1) · Last reviewed commit: "feat: switch between camera and picture ..." · Reviewed by Greptile

@sandchest-com

sandchest-com Bot commented Nov 23, 2026

Copy link
Copy Markdown

Sandchest

Sandchest reviewed 4047d7c: nothing exploitable found in this change.

Sandchest reviews every change for vulnerabilities an attacker could use · 12 credits · Review details

Comment on lines +3229 to +3234
/// A still picture, relative to the project, shown where the camera would
/// be in a recording that has no camera track. It sits outside `camera`
/// so presets and style segments, which copy `camera` whole, never carry
/// one project's picture into another.
#[serde(default, skip_serializing_if = "Option::is_none")]
pub camera_picture: Option<String>,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Presets remove the picture

preset_config saves camera_picture, but with_preset does not preserve the current project's value. Applying an older or built-in preset therefore removes the chosen picture. A default preset also removes the picture that finalize_studio just saved.

Exclude cameraPicture from saved presets and preserve the current project's value when applying them.

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/project/src/configuration.rs
Line: 3229-3234

Comment:
**Presets remove the picture**

`preset_config` saves `camera_picture`, but `with_preset` does not preserve the current project's value. Applying an older or built-in preset therefore removes the chosen picture. A default preset also removes the picture that `finalize_studio` just saved.

Exclude `cameraPicture` from saved presets and preserve the current project's value when applying them.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +38 to +39
let path = project_path.join(relative);
let frame = match decode_camera_picture(&path) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 security Projects can read outside images

relative comes from the saved cameraPicture field, but this join accepts absolute paths and ... A crafted project without a camera track can make the renderer read an image outside the project and include it in exported frames.

Reject paths that resolve outside the project, including links that point outside it.

How this was verified: Opening a project loads cameraPicture without a path check, and the export passes it to this loader and then to the camera layer.

Prompt To Fix With AI
This is a comment left during a code review.
Path: crates/rendering/src/camera_picture.rs
Line: 38-39

Comment:
**Projects can read outside images**

`relative` comes from the saved `cameraPicture` field, but this join accepts absolute paths and `..`. A crafted project without a camera track can make the renderer read an image outside the project and include it in exported frames.

Reject paths that resolve outside the project, including links that point outside it.

**How this was verified:** Opening a project loads `cameraPicture` without a path check, and the export passes it to this loader and then to the camera layer.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +1983 to +1987
let picture_aspect = feeds
.read(cx)
.camera_picture
.as_ref()
.map(|picture| picture.aspect());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Linux loses the picture position

Picture-only Studio recordings cannot save the bubble's position on Linux. studio_snapshot gets Linux bounds through recording_snapshot, which requires frame_dims from a delivered camera frame. A picture supplies no such frame, so no placement is saved and the editor falls back to its camera position.

Use the picture dimensions when taking this snapshot.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/camera_window.rs
Line: 1983-1987

Comment:
**Linux loses the picture position**

Picture-only Studio recordings cannot save the bubble's position on Linux. `studio_snapshot` gets Linux bounds through `recording_snapshot`, which requires `frame_dims` from a delivered camera frame. A picture supplies no such frame, so no placement is saved and the editor falls back to its camera position.

Use the picture dimensions when taking this snapshot.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Comment on lines +145 to +146
/// Normalizes `source` into the project, returning the path to store in
/// `ProjectConfiguration::camera_picture`.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Comments repeat the code

These descriptions repeat the function names and visible code. AGENTS.md requires comments to explain non-obvious context and explicitly bans narrating what code does. The same pattern appears above select_or_choose and load.

Remove these descriptions or keep only the parts that explain a real constraint. This repository requirement must be satisfied before merging.

Context Used: AGENTS.md (source)

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/desktop-gpui/src/camera_picture.rs
Line: 145-146

Comment:
**Comments repeat the code**

These descriptions repeat the function names and visible code. `AGENTS.md` requires comments to explain non-obvious context and explicitly bans narrating what code does. The same pattern appears above `select_or_choose` and `load`.

Remove these descriptions or keep only the parts that explain a real constraint. This repository requirement must be satisfied before merging.

**Context Used:** AGENTS.md ([source](https://github.com/capsoftware/cap/blob/main/AGENTS.md))

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!

@capy-ai capy-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Capy found 2 potential issues (2 medium).

View 2 other findings in Capy.

Open in Capy

Comment on lines +135 to +138
if let Ok(entries) = std::fs::read_dir(&dir) {
for entry in entries.flatten() {
if entry.path() != destination {
let _ = std::fs::remove_file(entry.path());

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pending imports can delete the active recording picture

Medium Severity

With picture A selected, choose B and start a Studio recording while normalization is pending. Startup never checks picking_camera_picture, so it retains A's path. This cleanup deletes A, then choose discards B because can_change is now false. Feeds and the restart configuration still reference the deleted file; restarting or making the next recording fails the picture copy and silently omits the picture. Retire the previous file only after the replacement is accepted, or block recording startup until import completes; a rejected import must preserve the selected asset.

Open in Capy

Some((
XY::new(picture.width(), picture.height()),
picture,
segment_frames.recording_time,

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replacing a picture leaves the paused preview showing the old image

Medium Severity

CameraLayer::prepare and prepare_with_encoder treat equal recording timestamps as identical frames even when frame storage changes. Replacing a picture while an ordinary Studio recording is paused supplies a new decoded image with the same timestamp here, so the layer skips uploading it and continues displaying the old texture until playback or seeking. The settled-preview reset does not rescue normal recordings: it is gated on the optional display-source.mp4 retained by certain imports. Invalidate the camera frame cache when the picture changes, or make still-frame upload identity independent of the recording timestamp in both preparation paths.

Open in Capy

This branch was successfully deployed

1 active deployment
Preview – cap-web — 4047d7c7 Deployed Nov 23, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant