Crate simple_editor

Source
Expand description

Simple Editor β€” a tiny, fast video trimmer/editor for Windows. simple-editor [file] open a video/project simple-editor --selftest [dir] headless engine check simple-editor [file] --screenshot out.ppm render the UI once and save it (for visual checks)

ModulesΒ§

contextmenu πŸ”’
Explorer context menu: β€œEdit with Simple Editor” for video files (HKCU, no admin needed). Appears in the classic menu (β€œShow more options” on Windows 11). Registered per extension because several video extensions (.mov/.m4v/.flv/.ts/.mts/.mpg) have no PerceivedType=video.
engine πŸ”’
Rendering / mixing / export engine. Pure CPU, RGBA8 + f32 audio. Shared by preview and export.
hotkeys πŸ”’
Keyboard shortcuts: a fixed list of actions, default bindings, user overrides (stored in Settings), and per-frame polling. The bare letters V / T / S / D / M belong to the tool strip (ui::tools), which consumes them before this table is polled, so actions that used them sit on Shift+. Mouse modifiers (Ctrl+Scroll zoom, Alt+Scroll track height, Shift+Scroll pan) are fixed and not part of this table.
mcp πŸ”’
MCP server so AI agents (Claude Code etc.) can co-edit live: Streamable HTTP transport (JSON-RPC 2.0 over HTTP POST /mcp on 127.0.0.1:, no external crates β€” a tiny HTTP/1.1 parser on std TcpListener), toggled in Settings. The server thread handles initialize, ping, tools/list, tools/call, resources/list, resources/read (project json, style summary, notes) and answers JSON (no SSE stream needed for request/response). Tool calls are forwarded to the UI thread as ToolCalls (the App executes them on the next frame against the live project, with undo, and replies through the oneshot sender); ctx.request_repaint() wakes the UI. Tool definitions (names, descriptions, JSON schemas) live in tools.rs β€” the App matches on the same names.
media πŸ”’
Media decoding: a small trait layer over two backends.
model πŸ”’
Project data model β€” the shared contract between UI, engine, playback and export. All times are seconds (f64). Keyframe times are clip-local (seconds from clip.start). Serialized with serde_json as the .sedit project format.
playback πŸ”’
Player: owns the render thread (Compositor + DecoderPool β†’ latest Frame) and the audio thread (Mixer + DecoderPool β†’ ring buffer β†’ cpal WASAPI output). The wall clock is the master when playing: time = base_time + elapsed. Video frames are rendered on the project fps grid (t quantized to frame index / fps, exactly like export) and published via take_frame; ctx.request_repaint() is called whenever a new frame is ready.
scripting πŸ”’
Embedded Luau scripting: .luau files in the scripts folder drive the editor through the same tool catalogue the MCP server exposes (editor.tool("timeline.add_clip", {...})). The VM is sandboxed (no io/os/ffi) and interrupted after a wall-clock budget so a runaway loop cannot hang the UI. Scripts run on the UI thread against the live project; the app wraps each run in one undo step.
selftest πŸ”’
simple-editor --selftest [dir] β€” headless end-to-end check (debug builds print to the console). Generates synthetic media with ffmpeg (solid colour segments + two sine audio streams), then verifies: probe β†’ project layout; video decode at known times (colour & seek accuracy) for both backends; audio decode RMS; compositor (blend/opacity/text layer); mixer; waveform peaks; export (mp4) β†’ ffprobe duration; lossless cut; xmeml is well-formed. Prints PASS/FAIL lines, returns 0 on success.
settings πŸ”’
App settings β€” one JSON file at %APPDATA%\SimpleEditor\settings.json.
theme πŸ”’
Match the user’s Windows theme: light/dark from the registry, accent colour from DWM. Bare, flat, Windows-Forms-ish visuals; DaVinci-like layout comes from the panels, not styling.
ui πŸ”’
egui UI. Dockable layout (ui/layout.rs) of panes: Library, Preview, Inspector, Effects, Transitions, Subtitles, Timeline, Curves, Planner, Auto-cut, Tracking β€” DaVinci-like by default, bare Windows-forms styling. Windows (Settings, Retime, Export) never block the editor.
winpos πŸ”’
Window placement: open on the monitor the user is actually on.

FunctionsΒ§

main πŸ”’