Skip to content

FEAT: video preview#231

Draft
firedotguy wants to merge 4 commits intoNSPC911:masterfrom
firedotguy:preview-video
Draft

FEAT: video preview#231
firedotguy wants to merge 4 commits intoNSPC911:masterfrom
firedotguy:preview-video

Conversation

@firedotguy
Copy link
Contributor

@firedotguy firedotguy commented Feb 28, 2026

Added video preview support
1772279570

Added new config variables:

  • interface.video_viewer
    • protocol
    • fps_decrease_factor
    • pause_icon_type
    • show_controls
    • show_track

resolves #210

by submitting this pull request, i agree that

  • i have run poe check to check for any style issues
  • i have tested both the dev version (in venv) and the built version (uv build then install) of rovr
  • cache, logs and others were not accidentally added to git's tracking history
  • my commits follow the conventional commits format as much as possible
  • the documentation has been updated wherever necessary

Summary by CodeRabbit

  • New Features

    • Video preview support for MP4 files with configurable playback (frame-rate adjustment, pause icon style, controls and track display).
    • Preview UI now includes a "Video Preview" title.
  • Chores

    • Added runtime dependency for video playback.
    • MIME rules updated to recognize MP4 as a video preview type.

@coderabbitai

This comment has been minimized.

@NSPC911
Copy link
Owner

NSPC911 commented Feb 28, 2026

oh, no wonder you opened #230

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (2)
src/rovr/config/schema.json (1)

107-111: Add a minimum bound for fps_decrease_factor.

Without a lower bound, invalid values (e.g., 0 or negatives) can pass schema validation.

🛠️ Suggested schema guard
             "fps_decrease_factor": {
               "type": "integer",
+              "minimum": 1,
               "default": 1,
               "description": "FPS decrease factor"
             },
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rovr/config/schema.json` around lines 107 - 111, The fps_decrease_factor
schema lacks a lower bound allowing 0 or negative values; update the
fps_decrease_factor property in schema.json (the JSON object named
"fps_decrease_factor") to include a "minimum": 1 (keeping "type": "integer" and
"default": 1) so validation rejects zero and negative values.
src/rovr/functions/path.py (1)

634-635: Prefer PreviewTypes | None over a duplicated Literal union.

This keeps the return type synchronized with PreviewTypes and avoids future drift.

♻️ Suggested refactor
 def match_mime_to_preview_type(
     widget: DOMNode,
     mime_type: str,
-) -> (
-    Literal["text", "image", "pdf", "archive", "folder", "remime", "resvg", "font", "video"]
-    | None
-):
+) -> PreviewTypes | None:
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rovr/functions/path.py` around lines 634 - 635, Replace the duplicated
Literal union type with the shared alias: change the annotation that currently
reads
Literal["text","image","pdf","archive","folder","remime","resvg","font","video"]
| None to use PreviewTypes | None so the signature (return or variable type)
stays synchronized with the PreviewTypes definition; update any import or
reference to PreviewTypes in the same module if needed and ensure type-checking
passes for functions/methods using this annotation (e.g., the function or
variable surrounding this annotation).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/rovr/classes/config.py`:
- Around line 834-835: The config now allows the "video" type but the generated
MIME defaults and docs were not updated: update the
_ROVR_CONFIG_INTERFACE_MIME_RULES_DEFAULT mapping to include the new entry
"video/mp4": "video" (and any equivalent video MIME(s) needed) and update the
mime_rules documentation string (the variable/docblock used to describe valid
mime types) to list "video" among the valid types so generated artifacts remain
consistent with the enum change.

In `@src/rovr/config/schema.json`:
- Around line 123-126: The "show_controls" JSON Schema property has a type
mismatch: its "default" is the string "true" but the schema "type" is boolean;
update the "show_controls" property's "default" to the boolean true (not a
quoted string) so the default value matches the declared type and avoids leaking
incorrectly typed defaults.

---

Nitpick comments:
In `@src/rovr/config/schema.json`:
- Around line 107-111: The fps_decrease_factor schema lacks a lower bound
allowing 0 or negative values; update the fps_decrease_factor property in
schema.json (the JSON object named "fps_decrease_factor") to include a
"minimum": 1 (keeping "type": "integer" and "default": 1) so validation rejects
zero and negative values.

In `@src/rovr/functions/path.py`:
- Around line 634-635: Replace the duplicated Literal union type with the shared
alias: change the annotation that currently reads
Literal["text","image","pdf","archive","folder","remime","resvg","font","video"]
| None to use PreviewTypes | None so the signature (return or variable type)
stays synchronized with the PreviewTypes definition; update any import or
reference to PreviewTypes in the same module if needed and ensure type-checking
passes for functions/methods using this annotation (e.g., the function or
variable surrounding this annotation).

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 59fdc5d and c5a9d2c.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • pyproject.toml
  • src/rovr/classes/config.py
  • src/rovr/classes/type_aliases.py
  • src/rovr/config/config.toml
  • src/rovr/config/schema.json
  • src/rovr/core/preview_container.py
  • src/rovr/functions/path.py
  • src/rovr/variables/constants.py

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

♻️ Duplicate comments (2)
src/rovr/classes/config.py (1)

834-835: ⚠️ Potential issue | 🟠 Major

Sync MIME defaults/docs with the new video preview type.

You added Literal["video"], but _ROVR_CONFIG_INTERFACE_MIME_RULES_DEFAULT (Line 75-95) still lacks "video/mp4": "video", and the mime_rules docs at Line 620 still omit video.

🛠️ Proposed fix
 _ROVR_CONFIG_INTERFACE_MIME_RULES_DEFAULT = {
@@
     "application/x-font-.*": "font",
+    "video/mp4": "video",
 }
@@
-    Map MIME type patterns to preview types. Uses regex patterns. Valid preview types: text, image, pdf, archive, folder, resvg, font, remime.
+    Map MIME type patterns to preview types. Uses regex patterns. Valid preview types: text, image, pdf, archive, folder, resvg, font, remime, video.
@@
       image/svg\+xml: resvg
       inode/directory: folder
+      video/mp4: video
       text/.*: text
     """
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rovr/classes/config.py` around lines 834 - 835, The config added
Literal["video"] but the defaults/docs weren't updated: add the video MIME
mapping to _ROVR_CONFIG_INTERFACE_MIME_RULES_DEFAULT (add "video/mp4": "video")
and update the mime_rules documentation entry that lists mappings to include the
video type so docs and defaults match the new preview type; reference the
symbols _ROVR_CONFIG_INTERFACE_MIME_RULES_DEFAULT and the mime_rules doc block
to make the edits.
src/rovr/config/schema.json (1)

123-126: ⚠️ Potential issue | 🟠 Major

Fix show_controls default type mismatch.

show_controls is declared as boolean, but Line 125 sets "default": "true" as a string. This can propagate wrong-typed config values.

🛠️ Proposed fix
             "show_controls": {
                 "type": "boolean",
-                "default": "true",
+                "default": true,
                 "description": "Whether to show player controls (pause button and time)"
             }
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/rovr/config/schema.json` around lines 123 - 126, The schema entry for
show_controls has a type mismatch: it's declared as boolean but the default is
the string "true"; update the default to a boolean value (true) in the
show_controls schema entry so the "default" matches the declared "type"
(reference symbol: show_controls in schema.json).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/rovr/config/schema.json`:
- Around line 107-110: The fps_decrease_factor schema currently allows zero and
negative values; add a lower bound to reject non-positive integers by adding a
"minimum": 1 constraint (or "exclusiveMinimum": 0 if you prefer) to the
fps_decrease_factor property in src/rovr/config/schema.json so validation
requires values >= 1; keep the existing "type": "integer" and "default": 3 and
update the description if needed to reflect the new constraint.

---

Duplicate comments:
In `@src/rovr/classes/config.py`:
- Around line 834-835: The config added Literal["video"] but the defaults/docs
weren't updated: add the video MIME mapping to
_ROVR_CONFIG_INTERFACE_MIME_RULES_DEFAULT (add "video/mp4": "video") and update
the mime_rules documentation entry that lists mappings to include the video type
so docs and defaults match the new preview type; reference the symbols
_ROVR_CONFIG_INTERFACE_MIME_RULES_DEFAULT and the mime_rules doc block to make
the edits.

In `@src/rovr/config/schema.json`:
- Around line 123-126: The schema entry for show_controls has a type mismatch:
it's declared as boolean but the default is the string "true"; update the
default to a boolean value (true) in the show_controls schema entry so the
"default" matches the declared "type" (reference symbol: show_controls in
schema.json).

ℹ️ Review info

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c5a9d2c and 402155a.

📒 Files selected for processing (4)
  • src/rovr/classes/config.py
  • src/rovr/config/config.toml
  • src/rovr/config/schema.json
  • src/rovr/core/preview_container.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/rovr/core/preview_container.py

@NSPC911
Copy link
Owner

NSPC911 commented Feb 28, 2026

This feature is capable of (and can) absolutely obliterate your memory. My memory usage spiked to 96% (it never hits 96%; memreduct keeps it below 90%). This is how badly this runs.

Sixel Renderer is also pretty bad; it flickers quite a lot.

Also, an extra few dependencies that I'm trying to avoid, like numpy and av, and maybe use the system's ffmpeg executable

├── textual-video v0.1.4
    ├── av v16.1.0
    ├── numpy v2.4.2
    ├── textual v7.5.0 (*)
    ├── textual-canvas v1.1.0
    │   ├── textual v7.5.0 (*)
    │   └── typing-extensions v4.15.0
    └── textual-image v0.8.5 (*)

@firedotguy
Copy link
Contributor Author

firedotguy commented Feb 28, 2026

This feature is capable of (and can) absolutely obliterate your memory

In future I want to add lazy loading

Sixel Renderer is also pretty bad; it flickers quite a lot.
What do you want? It is terminal. Recommendation is to use halfcell

Also, an extra few dependencies that I'm trying to avoid, like numpy and av, and maybe use the system's ffmpeg executable

agree, refactor is planned

@firedotguy firedotguy marked this pull request as draft February 28, 2026 13:15
@NSPC911
Copy link
Owner

NSPC911 commented Feb 28, 2026

In future I want to add lazy loading

Not just lazy loading, it also needs to destroy the objects. The thread also doesn't get cancelled when you exit (please use a multiprocessing.Process (it's cancellable) and poll for it being cancelled)

What do you want? It is terminal. Recommendation is to use halfcell

fair enough, this is python, what did I expect, but i was hoping it wouldn't be that often...

agree, refactor is planned

yes


it also managed to use 100% of my memory just now...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEAT] Video preview and playback (5fps)

2 participants