diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 2679fe0..0069883 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -67,6 +67,10 @@ jobs:
librsvg2-dev \
patchelf
+ # Tauri build.rs requires the host externalBin sidecar to exist.
+ - name: Fetch FFmpeg sidecar
+ run: ./scripts/fetch-ffmpeg.sh x86_64-unknown-linux-gnu
+
- name: Test
working-directory: src-tauri
run: cargo test
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index a5fe846..8b0bfdf 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -43,16 +43,20 @@ jobs:
- name: macOS (arm64)
platform: macos-latest
rust-targets: aarch64-apple-darwin
+ ffmpeg-triple: aarch64-apple-darwin
args: "--target aarch64-apple-darwin"
- name: macOS (x86_64)
platform: macos-latest
rust-targets: x86_64-apple-darwin
+ ffmpeg-triple: x86_64-apple-darwin
args: "--target x86_64-apple-darwin"
- name: Linux (x86_64)
platform: ubuntu-22.04
+ ffmpeg-triple: x86_64-unknown-linux-gnu
args: "--bundles appimage,deb"
- name: Windows (x86_64)
platform: windows-latest
+ ffmpeg-triple: x86_64-pc-windows-msvc
args: "--bundles nsis"
steps:
@@ -97,6 +101,10 @@ jobs:
- name: Install frontend dependencies
run: pnpm install --frozen-lockfile
+ - name: Fetch FFmpeg sidecar
+ shell: bash
+ run: ./scripts/fetch-ffmpeg.sh "${{ matrix.ffmpeg-triple }}"
+
- uses: tauri-apps/tauri-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.hallmark/log.json b/.hallmark/log.json
deleted file mode 100644
index 5e1e96c..0000000
--- a/.hallmark/log.json
+++ /dev/null
@@ -1,9 +0,0 @@
-[
- {
- "date": "2026-08-19",
- "macrostructure": "Stage+filmstrip",
- "theme": "existing tokens",
- "enrichment": "none",
- "brief": "Pour le web — destination photo, WebP quality-first + byte ceilings"
- }
-]
diff --git a/.impeccable/design.json b/.impeccable/design.json
new file mode 100644
index 0000000..d6e55c6
--- /dev/null
+++ b/.impeccable/design.json
@@ -0,0 +1,166 @@
+{
+ "schemaVersion": 2,
+ "generatedAt": "2026-11-03T08:00:00.000Z",
+ "title": "Design System: PictoolsApp",
+ "extensions": {
+ "colorMeta": {
+ "primary": {
+ "role": "primary",
+ "displayName": "Workbench Violet",
+ "canonical": "oklch(59.01% 0.19675 278.523)",
+ "tonalRamp": [
+ "oklch(25% 0.12 278.523)",
+ "oklch(35% 0.15 278.523)",
+ "oklch(45% 0.18 278.523)",
+ "oklch(59.01% 0.19675 278.523)",
+ "oklch(70% 0.14 278.523)",
+ "oklch(80% 0.08 278.523)",
+ "oklch(90% 0.04 278.523)",
+ "oklch(96% 0.015 278.523)"
+ ]
+ },
+ "secondary": {
+ "role": "secondary",
+ "displayName": "Done Mint",
+ "canonical": "oklch(78.158% 0.14381 171.311)",
+ "tonalRamp": [
+ "oklch(30% 0.08 171.311)",
+ "oklch(42% 0.1 171.311)",
+ "oklch(55% 0.12 171.311)",
+ "oklch(65% 0.13 171.311)",
+ "oklch(78.158% 0.14381 171.311)",
+ "oklch(85% 0.1 171.311)",
+ "oklch(92% 0.05 171.311)",
+ "oklch(97% 0.02 171.311)"
+ ]
+ },
+ "background": {
+ "role": "neutral",
+ "displayName": "Cool Paper",
+ "canonical": "oklch(98.511% 0.00011 271.152)",
+ "tonalRamp": [
+ "oklch(18% 0.002 286.055)",
+ "oklch(30% 0.002 286.055)",
+ "oklch(50% 0.01 278.523)",
+ "oklch(70% 0.005 278.523)",
+ "oklch(88% 0.005 278.523)",
+ "oklch(93% 0.00025 271.152)",
+ "oklch(96.5% 0.00015 271.152)",
+ "oklch(98.511% 0.00011 271.152)"
+ ]
+ }
+ },
+ "typographyMeta": {
+ "title": { "displayName": "Title", "purpose": "Tool page titles." },
+ "body": { "displayName": "Body", "purpose": "Supporting copy and dock summaries." },
+ "label": { "displayName": "Section label", "purpose": "Uppercase tracking labels above controls." },
+ "mono": { "displayName": "Mono", "purpose": "Sizes, versions, percents." }
+ },
+ "shadows": [],
+ "motion": [
+ {
+ "name": "page-enter",
+ "value": "opacity + 10px translate, 250ms cubic-bezier(0.16, 1, 0.3, 1)",
+ "purpose": "Page mount entrance via .page-enter."
+ },
+ {
+ "name": "interactive",
+ "value": "color/opacity 150–200ms",
+ "purpose": "Default interactive transitions."
+ },
+ {
+ "name": "cta-lift",
+ "value": "translateY(-1.5px) on hover; translateY(1px) on press",
+ "purpose": "Primary CTA press feedback; opacity-only under reduced motion."
+ }
+ ],
+ "breakpoints": []
+ },
+ "components": [
+ {
+ "name": "Primary Button",
+ "kind": "button",
+ "refersTo": "button-primary",
+ "description": "Verb-led filled CTA for run actions.",
+ "html": "",
+ "css": ".ds-btn-primary { background: var(--primary); color: var(--primary-foreground); border: none; border-radius: var(--radius); padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: transform 150ms ease, opacity 150ms ease; } .ds-btn-primary:hover { transform: translateY(-1.5px); } .ds-btn-primary:active { transform: translateY(1px); } .ds-btn-primary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; } .ds-btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }"
+ },
+ {
+ "name": "Secondary Button",
+ "kind": "button",
+ "refersTo": "button-secondary",
+ "description": "Outline secondary actions such as Open folder or Advanced.",
+ "html": "",
+ "css": ".ds-btn-secondary { background: transparent; color: var(--muted-foreground); border: 1px solid var(--border); border-radius: var(--radius); padding: 0.5rem 1rem; font-size: 0.875rem; font-weight: 500; cursor: pointer; transition: color 150ms ease, background 150ms ease; } .ds-btn-secondary:hover { color: var(--foreground); background: var(--muted); } .ds-btn-secondary:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }"
+ },
+ {
+ "name": "Format Chip On",
+ "kind": "chip",
+ "refersTo": "format-chip-on",
+ "description": "Selected format or preset chip.",
+ "html": "",
+ "css": ".ds-chip-on { background: var(--primary); color: var(--primary-foreground); border: none; border-radius: calc(var(--radius) - 2px); padding: 0.375rem 0.625rem; font-size: 0.75rem; font-weight: 500; cursor: pointer; } .ds-chip-on:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }"
+ },
+ {
+ "name": "Format Chip Off",
+ "kind": "chip",
+ "refersTo": "format-chip-off",
+ "description": "Idle format or preset chip.",
+ "html": "",
+ "css": ".ds-chip-off { background: var(--background); color: var(--muted-foreground); border: 1px solid color-mix(in oklch, var(--border) 60%, transparent); border-radius: calc(var(--radius) - 2px); padding: 0.375rem 0.625rem; font-size: 0.75rem; font-weight: 500; cursor: pointer; transition: background 150ms ease, color 150ms ease; } .ds-chip-off:hover { background: var(--accent); color: var(--accent-foreground); } .ds-chip-off:focus-visible { outline: 2px solid var(--ring); outline-offset: 2px; }"
+ },
+ {
+ "name": "Settings Card",
+ "kind": "card",
+ "refersTo": "card",
+ "description": "Bordered content card for Settings.",
+ "html": "
Language
Choose the interface language.
",
+ "css": ".ds-card { background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.25rem; } .ds-card-title { margin: 0 0 0.25rem; font-size: 0.875rem; font-weight: 600; } .ds-card-body { margin: 0; font-size: 0.75rem; color: var(--muted-foreground); }"
+ }
+ ],
+ "narrative": {
+ "northStar": "The Quiet Workbench",
+ "overview": "PictoolsApp is an operate surface where the media is the page. Empty tools are a full-canvas drop zone; loaded tools are stage + plan dock + horizontal filmstrip. Chrome stays thin and calm. Accent is rare; success is silent.",
+ "keyCharacteristics": [
+ "Stage + filmstrip macrostructure",
+ "System UI type only",
+ "Violet primary used sparingly; mint for done only",
+ "Flat tonal surfaces",
+ "Verb-led CTAs and segmented chips"
+ ],
+ "rules": [
+ {
+ "name": "The One Voice Rule",
+ "body": "Primary accent appears on ≤ ~5% of the viewport; rarity is the signal.",
+ "section": "colors"
+ },
+ {
+ "name": "The Mint Is Done Rule",
+ "body": "Secondary mint is reserved for success/done states only.",
+ "section": "colors"
+ },
+ {
+ "name": "The Flat-By-Default Rule",
+ "body": "Surfaces rest flat. Motion and tint carry state, not drop shadows.",
+ "section": "elevation"
+ },
+ {
+ "name": "The System Stack Rule",
+ "body": "Do not add display webfonts to tool pages.",
+ "section": "typography"
+ }
+ ],
+ "dos": [
+ "Keep tool pages stage-first with filmstrip + dock",
+ "Use silent success (check + size delta)",
+ "Preserve source files; force a suffix on path collision",
+ "Extend this system when adding tools"
+ ],
+ "donts": [
+ "Invent a second palette or loud enrichment on app pages",
+ "Add celebratory toasts on success",
+ "Restyle Home or Sidebar opportunistically",
+ "Overwrite source media"
+ ]
+ }
+}
diff --git a/DESIGN.md b/DESIGN.md
new file mode 100644
index 0000000..fab2ed7
--- /dev/null
+++ b/DESIGN.md
@@ -0,0 +1,171 @@
+---
+name: PictoolsApp
+description: Local-first media toolbox — calm operate UI, stage-first tools
+colors:
+ background: "oklch(98.511% 0.00011 271.152)"
+ foreground: "oklch(21.82% 0.00195 286.055)"
+ card: "oklch(96.5% 0.00015 271.152)"
+ primary: "oklch(59.01% 0.19675 278.523)"
+ primary-foreground: "oklch(98% 0 0)"
+ secondary: "oklch(78.158% 0.14381 171.311)"
+ muted: "oklch(93% 0.00025 271.152)"
+ muted-foreground: "oklch(50% 0.01 278.523)"
+ accent: "oklch(90% 0.04 278.523)"
+ destructive: "oklch(0.577 0.245 27.325)"
+ border: "oklch(88% 0.005 278.523)"
+ ring: "oklch(59.01% 0.19675 278.523)"
+typography:
+ title:
+ fontFamily: "ui-sans-serif, system-ui, sans-serif"
+ fontSize: "1.125rem"
+ fontWeight: 600
+ letterSpacing: "-0.025em"
+ body:
+ fontFamily: "ui-sans-serif, system-ui, sans-serif"
+ fontSize: "0.875rem"
+ fontWeight: 400
+ label:
+ fontFamily: "ui-sans-serif, system-ui, sans-serif"
+ fontSize: "0.75rem"
+ fontWeight: 500
+ letterSpacing: "0.1em"
+ mono:
+ fontFamily: "ui-monospace, SFMono-Regular, Menlo, monospace"
+ fontSize: "0.75rem"
+ fontWeight: 400
+rounded:
+ sm: "calc(0.625rem - 4px)"
+ md: "calc(0.625rem - 2px)"
+ lg: "0.625rem"
+spacing:
+ header-x: "1.25rem"
+ header-y: "0.75rem"
+ dock-x: "1.25rem"
+ dock-y: "0.75rem"
+ filmstrip-thumb: "6rem"
+components:
+ button-primary:
+ backgroundColor: "{colors.primary}"
+ textColor: "{colors.primary-foreground}"
+ rounded: "{rounded.lg}"
+ padding: "0.5rem 1rem"
+ button-secondary:
+ backgroundColor: "transparent"
+ textColor: "{colors.muted-foreground}"
+ rounded: "{rounded.lg}"
+ padding: "0.5rem 1rem"
+ format-chip-on:
+ backgroundColor: "{colors.primary}"
+ textColor: "{colors.primary-foreground}"
+ rounded: "{rounded.md}"
+ padding: "0.375rem 0.625rem"
+ format-chip-off:
+ backgroundColor: "{colors.background}"
+ textColor: "{colors.muted-foreground}"
+ rounded: "{rounded.md}"
+ padding: "0.375rem 0.625rem"
+---
+
+# Design System: PictoolsApp
+
+## Overview
+
+**Creative North Star: "The Quiet Workbench"**
+
+PictoolsApp is an operate surface, not a marketing spectacle. The media is the page: empty tools are a full-canvas drop zone; loaded tools are stage + plan dock + horizontal filmstrip. Chrome stays thin, utilitarian, and calm so attention stays on the file being processed.
+
+Personality is modern-minimal and restrained. Accent color is rare. Success is silent (check + size delta), never celebratory. Home keeps its centered wordmark; tool pages must not invent enrichment, second palettes, or dashboard chrome.
+
+**Key Characteristics:**
+- Stage + filmstrip macrostructure on tool pages
+- System UI type only; tight title tracking
+- Violet primary used sparingly; mint secondary for done/success only
+- Flat tonal surfaces; motion is short and optional
+- Verb-led CTAs; segmented format chips
+
+## Colors
+
+Cool near-white paper with a restrained violet accent and a mint reserved for completion.
+
+### Primary
+- **Workbench Violet** (`oklch(59.01% 0.19675 278.523)`): primary CTA fill, selected chips, focus ring, active nav bar. ≤ ~5% of any viewport.
+
+### Secondary
+- **Done Mint** (`oklch(78.158% 0.14381 171.311)`): success / done indicators only — never as a second brand accent on idle chrome.
+
+### Neutral
+- **Cool Paper** (`oklch(98.511% 0.00011 271.152)`): app background
+- **Ink** (`oklch(21.82% 0.00195 286.055)`): body text
+- **Card Mist** (`oklch(96.5% 0.00015 271.152)`): cards / elevated panels
+- **Mute Wash** (`oklch(93% 0.00025 271.152)`): muted fills, active nav row
+- **Hairline** (`oklch(88% 0.005 278.523)`): borders and inputs
+
+### Named Rules
+**The One Voice Rule.** Primary accent appears on ≤ ~5% of the viewport; rarity is the signal.
+
+**The Mint Is Done Rule.** Secondary mint is reserved for success/done states only.
+
+## Typography
+
+**Display / Body Font:** system UI stack (`ui-sans-serif, system-ui, sans-serif`)
+**Mono Font:** system mono for sizes, versions, percents
+
+**Character:** Quiet OS-native type. No webfonts. Hierarchy comes from size, weight, and tracking — not personality typefaces.
+
+### Hierarchy
+- **Title** (600, `text-lg`, tight tracking): tool page titles
+- **Body** (400, `text-sm`): supporting copy, dock summaries
+- **Label** (500, `text-xs`, uppercase, `tracking-widest`, muted): section labels above controls
+- **Mono** (400, `text-xs`): byte sizes, dimensions, percents
+
+### Named Rules
+**The System Stack Rule.** Do not add display webfonts to tool pages.
+
+## Layout
+
+Desktop operate shell: custom TopBar + collapsible Sidebar + content outlet. Tool pages share header rhythm `px-5 py-3`, edge-to-edge stage, dock `px-5 py-3`, filmstrip thumbs `w-24` with horizontal scroll. No three-pane settings workbench on media tools. Settings uses bordered cards and the same header rhythm. Home stays a centered wordmark composition.
+
+Spacing follows Tailwind’s 4-point scale. Density is comfortable but chrome-light — the file owns the canvas.
+
+## Elevation & Depth
+
+Flat by default. Depth comes from tonal layering (background → card → muted) and hairline borders, not multi-layer shadows. Interactive lift on primary CTAs is a 1.5px translate on hover (opacity-only under reduced motion).
+
+### Named Rules
+**The Flat-By-Default Rule.** Surfaces rest flat. Motion and tint carry state, not drop shadows.
+
+## Shapes
+
+Base radius `--radius: 0.625rem` with sm/md/lg steps derived in CSS. Buttons and chips use `rounded-lg` / `rounded-md`. Cards and settings panels use the same radius language with `border-border`. No pill-full chrome on primary actions.
+
+## Components
+
+### Buttons
+Primary: filled primary, `rounded-lg`, verb label, hover lift 1.5px, press `translateY(1px)`. Secondary: outline `border-border`, muted text. Disabled only while in-flight or missing required inputs (files; Convert also needs output folder).
+
+### Format chips
+Segmented control feel: selected = primary fill; idle = background + hairline border + muted text.
+
+### Tool workbench
+Header (icon + title + subtitle) → stage (empty drop or media preview) → optional dock → optional filmstrip. Drag overlay and busy overlay are first-class states.
+
+### Sidebar / TopBar
+Shared shell. Active nav: muted fill + 2px primary left bar. Tooltips delay 300ms on hover. Do not restyle Home or Sidebar as part of tool work.
+
+### Settings cards
+Bordered cards only; no stage, no enrichment.
+
+## Do's and Don'ts
+
+**Do**
+- Keep tool pages stage-first with filmstrip + dock
+- Use silent success (check + size delta)
+- Preserve source files; force a suffix on path collision
+- Extend this system when adding tools (Video matches Convert/Optimize chrome)
+
+**Don't**
+- Invent a second palette or loud enrichment on app pages
+- Add celebratory toasts/confetti on convert/optimize/video success
+- Restyle Home or Sidebar opportunistically
+- Expose encoder knobs when presets carry the product voice
+- Overwrite source media
diff --git a/PRODUCT.md b/PRODUCT.md
new file mode 100644
index 0000000..a3cd9c6
--- /dev/null
+++ b/PRODUCT.md
@@ -0,0 +1,68 @@
+# Product
+
+
+
+## Platform
+
+web
+
+## Users
+
+People who need to convert, compress, or prepare images and videos on their own machine — freelancers, developers, and anyone tired of uploading media to untrusted websites. They work locally, often in short task bursts: drop files, pick an output, leave with smaller or converted files.
+
+## Product Purpose
+
+PictoolsApp is a local-first media toolbox. It converts and optimizes images (and video) entirely on-device so files never leave the computer. Success means fast, predictable offline processing with clear progress and no account, upload, or third-party server.
+
+## Positioning
+
+Offline media tools that stay on the user’s machine — not a browser SaaS, not a cloud encoder. Processing runs in the desktop app (Rust + bundled codecs); privacy and speed are the product, not a feature checklist.
+
+## Operating Context
+
+Desktop app (Tauri v2) on macOS, Windows, and Linux. Typical flow: open a tool from the sidebar, drag-and-drop or pick files, choose format/preset and output folder, run, then open the result folder. Languages: English and French (in-app Settings). Home is a quiet wordmark landing; tools use a stage + filmstrip workbench.
+
+## Capabilities and Constraints
+
+Confirmed:
+- Image conversion: PNG, JPEG, WEBP, ICO; App Icons pack (PNG + ICNS + ICO)
+- Image optimize « Pour le web »: resize ceilings, WebP/JPEG quality search, never overwrite sources
+- Video compress + convert (presets light / balanced / quality; outputs mp4, webm, mov, mkv) via bundled FFmpeg sidecar
+- Drag-and-drop, file picker, per-file progress events
+- Auto-updater for shipped builds
+
+Constraints:
+- Local-only: no uploads, no remote processing APIs
+- Never overwrite source files; force a suffix when paths collide
+- FFmpeg is GPL: the sidecar binary’s license obligations apply to distribution of builds that include it
+- Impeccable Live mode is not available inside the Tauri webview; design work uses PRODUCT.md / DESIGN.md and shipped UI inspection
+
+Undecided / out of current scope:
+- Advanced video controls (manual CRF, AV1, fine audio routing)
+- Cloud sync, accounts, collaboration
+
+## Brand Commitments
+
+- Name: PictoolsApp
+- Voice: utilitarian, calm, verb-led CTAs (“Convert”, “Ready for the web”); silent success (no celebratory toasts)
+- Assets: wordmark / logo in TopBar and Home (`public/Base Logo.png`)
+- Visual world is owned by DESIGN.md; do not invent a second palette on tool pages
+
+## Evidence on Hand
+
+- README product story and feature list
+- Implemented tools: Convert, Optimize, Settings; Home landing
+- Design tokens and workbench in `src/index.css` and `src/components/workbench/`
+- No fabricated testimonials, benchmarks, or customer quotes — do not invent them
+
+## Product Principles
+
+1. Files stay on the machine — privacy is default, not a setting.
+2. Tools are destinations: one job per page, stage-first, minimal chrome.
+3. Silent success: show size deltas and checks, not confetti.
+4. Never destroy the original; always write beside or into a chosen folder.
+5. Prefer clear presets over exposed encoder knobs unless the user asks for advanced control.
+
+## Accessibility & Inclusion
+
+Keyboard-reachable controls and focus-visible styles on interactive chrome. Respect `prefers-reduced-motion` (opacity-only where motion exists). Full UI available in English and French.
diff --git a/README.md b/README.md
index 6573025..5b8f11e 100644
--- a/README.md
+++ b/README.md
@@ -15,17 +15,17 @@ PictoolsApp does the same job offline, instantly, with no data leaving your comp
## What it does
- **Image conversion** — PNG, JPEG, WEBP, ICO (per-size files), and a full **App Icons** pack in one click: PNG set + `.icns` (macOS) + `.ico` (Windows) + Windows Store sizes
+- **Optimize for the web** — resize ceilings, WebP/JPEG targeting, originals never overwritten
+- **Video compress / convert** — presets (smaller / balanced / higher quality) and MP4, WebM, MOV, MKV via a bundled FFmpeg sidecar
- Drag & drop or file picker
- Live progress feedback per file during conversion
- Output folder of your choice
-More tools are planned.
-
## Stack
Built with [Tauri v2](https://tauri.app) + [React 19](https://react.dev) + [TypeScript](https://www.typescriptlang.org).
-Image processing runs entirely in Rust — [`image`](https://crates.io/crates/image), [`ico`](https://crates.io/crates/ico), [`icns`](https://crates.io/crates/icns). No native system dependencies required.
+Image processing runs in Rust — [`image`](https://crates.io/crates/image), [`ico`](https://crates.io/crates/ico), [`icns`](https://crates.io/crates/icns). Video uses a bundled FFmpeg sidecar (fetched at build time, not committed).
UI: [Tailwind CSS v4](https://tailwindcss.com) · [shadcn/ui](https://ui.shadcn.com) · [Lucide](https://lucide.dev) · [Radix UI](https://www.radix-ui.com)
@@ -37,15 +37,19 @@ UI: [Tailwind CSS v4](https://tailwindcss.com) · [shadcn/ui](https://ui.shadcn.
git clone https://github.com/Onivoid/PictoolsApp
cd PictoolsApp
pnpm install
+./scripts/fetch-ffmpeg.sh # required for the Video tool (sidecar, not committed)
pnpm tauri dev
```
Build a distributable:
```bash
+./scripts/fetch-ffmpeg.sh
pnpm tauri build
```
+GitHub Releases already fetch the matching FFmpeg binary per OS/arch in `.github/workflows/release.yml`.
+
## i18n
Fully translated in **English** and **French**. Language can be switched from the Settings page inside the app.
diff --git a/design.md b/design.md
deleted file mode 100644
index e6b4567..0000000
--- a/design.md
+++ /dev/null
@@ -1,85 +0,0 @@
-# Design — PictoolsApp
-
-A locked design system for this app. Every page redesign reads this file before
-emitting code. Do not regenerate per page — extend or amend this file when the
-system needs to grow.
-
-## Genre
-modern-minimal
-
-## Macrostructure family
-- Marketing pages: Home stays as-is (centered wordmark + subtitle). Do not restyle.
-- App pages: Stage + filmstrip. The photo is the page. Empty = full-canvas drop.
- Loaded = stage (before/after) + plan dock + horizontal filmstrip. No three-pane
- settings workbench.
-- Content pages: Settings uses the same header rhythm and bordered cards, no enrichment.
-
-## Theme
-Existing tokens in `src/index.css`. Do not invent a second palette.
-
-- `--background` oklch(98.511% 0.00011 271.152) (dark: oklch(18% 0.002 286.055))
-- `--foreground` oklch(21.82% 0.00195 286.055)
-- `--card` oklch(96.5% 0.00015 271.152)
-- `--primary` oklch(59.01% 0.19675 278.523) — violet accent, ≤ 5% of viewport
-- `--secondary` oklch(78.158% 0.14381 171.311) — mint, success/done only
-- `--muted` oklch(93% 0.00025 271.152)
-- `--destructive` oklch(0.577 0.245 27.325)
-- `--border` oklch(88% 0.005 278.523)
-- `--radius` 0.625rem
-
-## Typography
-- Display / body: inherited system UI stack (no extra webfont).
-- Mono: system mono for sizes, versions, percents.
-- Headings: roman, `font-style: normal`. Tracking tight on titles (`tracking-tight`).
-- App page title: `text-lg font-semibold`. Section labels: `text-xs uppercase tracking-widest text-muted-foreground`.
-
-## Spacing
-4-point scale via Tailwind.
-- Header: `px-5 py-3`.
-- Stage: edge-to-edge, no side columns.
-- Dock: `px-5 py-3`.
-- Filmstrip thumbs: `w-24`, horizontal scroll.
-
-## Motion
-- Page enter: `.page-enter` (opacity + 10px translate, 250ms).
-- Interactive: color/opacity 150–200ms. Transforms only on hover of chrome already using them (Home, Sidebar).
-- CTA: 1.5px lift on hover, press `translateY(1px)`. Reduced-motion: opacity only.
-- Reduced-motion: existing `useReducedMotion` — keep opacity-only there.
-- App pages: no celebratory toasts. Silent success (check icon + size delta).
-
-## Microinteractions stance
-- Silent success. No confetti, no extra toast on optimize/convert.
-- Hover delay on tooltips 300ms (sidebar). Focus delay 0ms.
-- Primary CTA disabled only while in-flight or missing files (and Convert: missing output folder).
-
-## CTA voice
-- Primary: filled `--primary`, `rounded-lg`, verb label (“Prêt pour le web”, “Convertir”).
-- Secondary: outline `border-border`, muted text (“Ouvrir le dossier”, “Avancé”).
-- Segmented format chips: selected = primary fill.
-
-## Per-page allowances
-- Home MAY keep its existing logo motion. Do not restyle Home or Sidebar.
-- App pages MUST NOT use enrichment — function carries the page.
-- Settings: cards only.
-
-## What pages MUST share
-- Wordmark / logotype in the TopBar.
-- Accent colour and placement.
-- Display + body fonts (system stack).
-- CTA voice (button shape, radius, padding).
-- Section heading rhythm (uppercase tracking label above controls).
-- Stage + filmstrip chrome on Convert and Optimize.
-
-## What pages MAY differ on
-- Convert dock content (format chips + folder) vs Optimize dock (plan + one CTA).
-- Settings has no stage.
-
-## Notes
-- App pages are destinations, not settings panels. Optimize is « Pour le web »: detect orientation, show the plan, one CTA.
-- Web fit (no crop, no upscale): landscape max 1920 wide, portrait max 1350 tall, square max 1080.
-- Web profile encodes WebP at quality 78 (JPEG 82 if forced), then drops toward quality 55 only to hit the ceiling. Never climbs to quality 100.
-- Web ceilings after fit: landscape 300 KiB, portrait 220 KiB, square 200 KiB.
-- `keep_percent` is ignored by the web profile. The slider lives in Advanced for custom (non-web) runs only.
-- Never overwrite the source file: if output path equals input path, force a suffix.
-- Default web output sits next to the source with `_web`.
-- PNG output is lossless; the UI must say so instead of pretending the slider will shrink it.
diff --git a/package.json b/package.json
index 6e2886c..b44ab84 100644
--- a/package.json
+++ b/package.json
@@ -1,7 +1,7 @@
{
"name": "pictoolsapp",
"private": true,
- "version": "0.3.5",
+ "version": "0.4.10",
"type": "module",
"scripts": {
"dev": "vite",
@@ -19,6 +19,7 @@
"@tauri-apps/plugin-notification": "^2.3.3",
"@tauri-apps/plugin-opener": "^2.5.3",
"@tauri-apps/plugin-process": "^2.3.1",
+ "@tauri-apps/plugin-shell": "^2.6.0",
"@tauri-apps/plugin-updater": "^2.10.0",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
@@ -47,5 +48,10 @@
"packageManager": "pnpm@10.28.2+sha512.41872f037ad22f7348e3b1debbaf7e867cfd448f2726d9cf74c08f19507c31d2c8e7a11525b983febc2df640b5438dee6023ebb1f84ed43cc2d654d2bc326264",
"engines": {
"node": ">=24"
+ },
+ "pnpm": {
+ "onlyBuiltDependencies": [
+ "esbuild"
+ ]
}
}
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 9013e52..2693e96 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -32,6 +32,9 @@ importers:
'@tauri-apps/plugin-process':
specifier: ^2.3.1
version: 2.3.1
+ '@tauri-apps/plugin-shell':
+ specifier: ^2.6.0
+ version: 2.6.0
'@tauri-apps/plugin-updater':
specifier: ^2.10.0
version: 2.10.0
@@ -832,6 +835,9 @@ packages:
'@tauri-apps/api@2.10.1':
resolution: {integrity: sha512-hKL/jWf293UDSUN09rR69hrToyIXBb8CjGaWC7gfinvnQrBVvnLr08FeFi38gxtugAVyVcTa5/FD/Xnkb1siBw==}
+ '@tauri-apps/api@2.12.4':
+ resolution: {integrity: sha512-pVmfis+4zT8H0Qhp3xPZx9Ju7kpzvA6rr/PSJPyuwfvucTQ8sVt61NYU9KMkK703UFlYadFmjKA4HhybOtN0gg==}
+
'@tauri-apps/cli-darwin-arm64@2.10.0':
resolution: {integrity: sha512-avqHD4HRjrMamE/7R/kzJPcAJnZs0IIS+1nkDP5b+TNBn3py7N2aIo9LIpy+VQq0AkN8G5dDpZtOOBkmWt/zjA==}
engines: {node: '>= 10'}
@@ -920,6 +926,9 @@ packages:
'@tauri-apps/plugin-process@2.3.1':
resolution: {integrity: sha512-nCa4fGVaDL/B9ai03VyPOjfAHRHSBz5v6F/ObsB73r/dA3MHHhZtldaDMIc0V/pnUw9ehzr2iEG+XkSEyC0JJA==}
+ '@tauri-apps/plugin-shell@2.6.0':
+ resolution: {integrity: sha512-z9LZGSr8jfD0FWWJ+CdD99i2FQcmJ26ebNJlYJdrlFdMLcggUS29BYrfS4hJlXO1UAI6A6r084vJUAG5734Y6w==}
+
'@tauri-apps/plugin-updater@2.10.0':
resolution: {integrity: sha512-ljN8jPlnT0aSn8ecYhuBib84alxfMx6Hc8vJSKMJyzGbTPFZAC44T2I1QNFZssgWKrAlofvJqCC6Rr472JWfkQ==}
@@ -1923,6 +1932,8 @@ snapshots:
'@tauri-apps/api@2.10.1': {}
+ '@tauri-apps/api@2.12.4': {}
+
'@tauri-apps/cli-darwin-arm64@2.10.0':
optional: true
@@ -1986,6 +1997,10 @@ snapshots:
dependencies:
'@tauri-apps/api': 2.10.1
+ '@tauri-apps/plugin-shell@2.6.0':
+ dependencies:
+ '@tauri-apps/api': 2.12.4
+
'@tauri-apps/plugin-updater@2.10.0':
dependencies:
'@tauri-apps/api': 2.10.1
diff --git a/scripts/fetch-ffmpeg.sh b/scripts/fetch-ffmpeg.sh
new file mode 100755
index 0000000..48a1326
--- /dev/null
+++ b/scripts/fetch-ffmpeg.sh
@@ -0,0 +1,104 @@
+#!/usr/bin/env bash
+# Download FFmpeg builds into src-tauri/binaries/ with Tauri sidecar naming.
+set -euo pipefail
+
+ROOT="$(cd "$(dirname "$0")/.." && pwd)"
+BIN_DIR="$ROOT/src-tauri/binaries"
+# Static macOS/Windows builds from eugeneware/ffmpeg-static (b6.0)
+FFMPEG_STATIC_TAG="b6.0"
+mkdir -p "$BIN_DIR"
+
+host_triple() {
+ rustc -vV | sed -n 's/^host: //p'
+}
+
+download_gzip_binary() {
+ local url="$1"
+ local dest="$2"
+ local tmp
+ tmp="$(mktemp)"
+ curl -fsSL "$url" -o "$tmp"
+ gzip -dc "$tmp" > "$dest"
+ chmod 755 "$dest"
+ rm -f "$tmp"
+}
+
+download_macos() {
+ local triple="$1"
+ local arch url
+ case "$triple" in
+ aarch64-apple-darwin) arch="darwin-arm64" ;;
+ x86_64-apple-darwin) arch="darwin-x64" ;;
+ *)
+ echo "Unsupported macOS triple: $triple" >&2
+ return 1
+ ;;
+ esac
+ url="https://github.com/eugeneware/ffmpeg-static/releases/download/${FFMPEG_STATIC_TAG}/ffmpeg-${arch}.gz"
+ echo "→ macOS FFmpeg for ${triple}"
+ download_gzip_binary "$url" "$BIN_DIR/ffmpeg-${triple}"
+ echo " ✓ $BIN_DIR/ffmpeg-${triple}"
+}
+
+download_windows() {
+ local triple="x86_64-pc-windows-msvc"
+ local url="https://github.com/eugeneware/ffmpeg-static/releases/download/${FFMPEG_STATIC_TAG}/ffmpeg-win32-x64.gz"
+ echo "→ Windows FFmpeg for ${triple}"
+ download_gzip_binary "$url" "$BIN_DIR/ffmpeg-${triple}.exe"
+ echo " ✓ $BIN_DIR/ffmpeg-${triple}.exe"
+}
+
+download_linux() {
+ local triple="$1"
+ local arch url
+ case "$triple" in
+ x86_64-unknown-linux-gnu) arch="linux-x64" ;;
+ aarch64-unknown-linux-gnu) arch="linux-arm64" ;;
+ *)
+ echo "Unsupported Linux triple: $triple" >&2
+ return 1
+ ;;
+ esac
+ url="https://github.com/eugeneware/ffmpeg-static/releases/download/${FFMPEG_STATIC_TAG}/ffmpeg-${arch}.gz"
+ echo "→ Linux FFmpeg for ${triple}"
+ download_gzip_binary "$url" "$BIN_DIR/ffmpeg-${triple}"
+ echo " ✓ $BIN_DIR/ffmpeg-${triple}"
+}
+
+fetch_one() {
+ local triple="$1"
+ case "$triple" in
+ aarch64-apple-darwin|x86_64-apple-darwin)
+ download_macos "$triple"
+ ;;
+ x86_64-pc-windows-msvc)
+ download_windows
+ ;;
+ x86_64-unknown-linux-gnu|aarch64-unknown-linux-gnu)
+ download_linux "$triple"
+ ;;
+ *)
+ echo "No fetch recipe for triple: $triple" >&2
+ return 1
+ ;;
+ esac
+}
+
+main() {
+ local arg="${1:-}"
+ if [[ "$arg" == "--all" ]]; then
+ fetch_one aarch64-apple-darwin
+ fetch_one x86_64-apple-darwin
+ fetch_one x86_64-pc-windows-msvc
+ fetch_one x86_64-unknown-linux-gnu
+ fetch_one aarch64-unknown-linux-gnu
+ elif [[ -n "$arg" ]]; then
+ # Explicit triple for CI / cross builds (e.g. x86_64-apple-darwin on arm64 runners)
+ fetch_one "$arg"
+ else
+ fetch_one "$(host_triple)"
+ fi
+ echo "Done."
+}
+
+main "$@"
diff --git a/src-tauri/.gitignore b/src-tauri/.gitignore
index b21bd68..61efd4f 100644
--- a/src-tauri/.gitignore
+++ b/src-tauri/.gitignore
@@ -5,3 +5,8 @@
# Generated by Tauri
# will have schema files for capabilities auto-completion
/gen/schemas
+
+# FFmpeg sidecars (fetched via scripts/fetch-ffmpeg.sh)
+/binaries/ffmpeg-*
+!/binaries/.gitkeep
+!/binaries/README.md
diff --git a/src-tauri/Cargo.lock b/src-tauri/Cargo.lock
index 989fc5f..90f75ab 100644
--- a/src-tauri/Cargo.lock
+++ b/src-tauri/Cargo.lock
@@ -662,6 +662,12 @@ dependencies = [
"memchr",
]
+[[package]]
+name = "core_detect"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7f8f80099a98041a3d1622845c271458a2d73e688351bf3cb999266764b81d48"
+
[[package]]
name = "cpufeatures"
version = "0.2.17"
@@ -991,6 +997,20 @@ version = "1.2.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4ef6b89e5b37196644d8796de5268852ff179b44e96276cf4290264843743bb7"
+[[package]]
+name = "encoding_rs"
+version = "0.8.44"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "89253175e704ab869b04f9db224d38630e0211a53841a79181deae0889e169f5"
+dependencies = [
+ "cfg-if",
+ "core_detect",
+ "multiversion_no_op",
+ "rustversion",
+ "scopeguard",
+ "simdutf8",
+]
+
[[package]]
name = "endi"
version = "1.1.1"
@@ -2456,6 +2476,12 @@ dependencies = [
"windows-sys 0.60.2",
]
+[[package]]
+name = "multiversion_no_op"
+version = "1.0.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "743fb55ba31b18fb1ecef6bdc9aa2743314978ac084044301a7eee33fb99a20d"
+
[[package]]
name = "ndk"
version = "0.9.0"
@@ -2869,6 +2895,16 @@ dependencies = [
"pin-project-lite",
]
+[[package]]
+name = "os_pipe"
+version = "1.2.3"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "7d8fae84b431384b68627d0f9b3b1245fcf9f46f6c0e3dc902e9dce64edd1967"
+dependencies = [
+ "libc",
+ "windows-sys 0.61.2",
+]
+
[[package]]
name = "osakit"
version = "0.3.1"
@@ -3110,6 +3146,7 @@ dependencies = [
"tauri-plugin-notification",
"tauri-plugin-opener",
"tauri-plugin-process",
+ "tauri-plugin-shell",
"tauri-plugin-updater",
"tokio",
"webp",
@@ -4126,12 +4163,44 @@ dependencies = [
"digest",
]
+[[package]]
+name = "shared_child"
+version = "1.1.2"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "607549934f6cc26b89cfecfdc46fa90f1e5d1536a68349b0c3a4f9d1c0d37959"
+dependencies = [
+ "libc",
+ "sigchld",
+ "windows-sys 0.61.2",
+]
+
[[package]]
name = "shlex"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64"
+[[package]]
+name = "sigchld"
+version = "0.2.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "24f2b37f04360cd465089b87a9c3869c08220a2f3458463f0adf8badf5e77f2c"
+dependencies = [
+ "libc",
+ "os_pipe",
+ "signal-hook",
+]
+
+[[package]]
+name = "signal-hook"
+version = "0.4.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "49f7447afd772ca79ad17ae0a3972a6b0df0cb4b80990fd82707593e9e012a74"
+dependencies = [
+ "libc",
+ "signal-hook-registry",
+]
+
[[package]]
name = "signal-hook-registry"
version = "1.4.8"
@@ -4157,6 +4226,12 @@ dependencies = [
"quote",
]
+[[package]]
+name = "simdutf8"
+version = "0.1.5"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "e3a9fe34e3e7a50316060351f37187a3f546bce95496156754b601a5fa71b76e"
+
[[package]]
name = "siphasher"
version = "0.3.11"
@@ -4639,6 +4714,27 @@ dependencies = [
"tauri-plugin",
]
+[[package]]
+name = "tauri-plugin-shell"
+version = "2.3.6"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "8548af174c5516e4f71f142acea4d02e00316296ea9aafa58798851481003e3c"
+dependencies = [
+ "encoding_rs",
+ "log",
+ "open",
+ "os_pipe",
+ "regex",
+ "schemars 0.8.22",
+ "serde",
+ "serde_json",
+ "shared_child",
+ "tauri",
+ "tauri-plugin",
+ "thiserror 2.0.18",
+ "tokio",
+]
+
[[package]]
name = "tauri-plugin-updater"
version = "2.10.0"
diff --git a/src-tauri/Cargo.toml b/src-tauri/Cargo.toml
index e6952c2..70876eb 100644
--- a/src-tauri/Cargo.toml
+++ b/src-tauri/Cargo.toml
@@ -26,6 +26,7 @@ serde_json = "1"
tauri-plugin-updater = "2.10.0"
tauri-plugin-process = "2.3.1"
tauri-plugin-dialog = "2"
+tauri-plugin-shell = "2"
image = { version = "0.25", features = ["png", "jpeg", "webp"] }
webp = "0.3"
ico = "0.3"
diff --git a/src-tauri/binaries/.gitkeep b/src-tauri/binaries/.gitkeep
new file mode 100644
index 0000000..e69de29
diff --git a/src-tauri/binaries/README.md b/src-tauri/binaries/README.md
new file mode 100644
index 0000000..94dd8c1
--- /dev/null
+++ b/src-tauri/binaries/README.md
@@ -0,0 +1,29 @@
+# FFmpeg sidecars
+
+Tauri expects one binary per Rust target triple next to this README:
+
+- `ffmpeg-aarch64-apple-darwin`
+- `ffmpeg-x86_64-apple-darwin`
+- `ffmpeg-x86_64-pc-windows-msvc.exe`
+- `ffmpeg-x86_64-unknown-linux-gnu`
+- `ffmpeg-aarch64-unknown-linux-gnu`
+
+Fetch the host binary locally:
+
+```bash
+./scripts/fetch-ffmpeg.sh
+```
+
+Fetch a specific target (GitHub Actions release matrix):
+
+```bash
+./scripts/fetch-ffmpeg.sh aarch64-apple-darwin
+./scripts/fetch-ffmpeg.sh x86_64-pc-windows-msvc
+```
+
+Pass `--all` to download every supported target.
+
+Binaries are gitignored — they are GPL-licensed and large.
+
+- **CI** (`.github/workflows/ci.yml`): fetches the Linux sidecar before `cargo test` / Clippy — Tauri’s build script fails if the host `externalBin` is missing.
+- **Release** (`.github/workflows/release.yml`): fetches the matching sidecar per OS/arch before `tauri-action` bundles it.
diff --git a/src-tauri/capabilities/default.json b/src-tauri/capabilities/default.json
index 896b60e..0b114c4 100644
--- a/src-tauri/capabilities/default.json
+++ b/src-tauri/capabilities/default.json
@@ -26,6 +26,26 @@
"dialog:allow-open",
"core:window:allow-start-dragging",
"core:path:default",
- "core:event:default"
+ "core:event:default",
+ {
+ "identifier": "shell:allow-execute",
+ "allow": [
+ {
+ "name": "binaries/ffmpeg",
+ "sidecar": true,
+ "args": true
+ }
+ ]
+ },
+ {
+ "identifier": "shell:allow-spawn",
+ "allow": [
+ {
+ "name": "binaries/ffmpeg",
+ "sidecar": true,
+ "args": true
+ }
+ ]
+ }
]
}
diff --git a/src-tauri/src/commands/mod.rs b/src-tauri/src/commands/mod.rs
index 383f4a2..d3cca15 100644
--- a/src-tauri/src/commands/mod.rs
+++ b/src-tauri/src/commands/mod.rs
@@ -3,8 +3,10 @@ pub mod convert;
pub mod encode;
pub mod optimize;
pub mod system;
+pub mod video;
pub use app_icons::*;
pub use convert::*;
pub use optimize::*;
pub use system::*;
+pub use video::*;
diff --git a/src-tauri/src/commands/video.rs b/src-tauri/src/commands/video.rs
new file mode 100644
index 0000000..62c58d7
--- /dev/null
+++ b/src-tauri/src/commands/video.rs
@@ -0,0 +1,558 @@
+use crate::ffmpeg::ffmpeg_command;
+use serde::{Deserialize, Serialize};
+use std::path::{Path, PathBuf};
+use tauri::{AppHandle, Emitter};
+use tauri_plugin_shell::process::CommandEvent;
+
+const DEFAULT_SUFFIX: &str = "_compressed";
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct VideoOptions {
+ pub preset: String,
+ pub output_format: String,
+ pub output_naming: String,
+ pub custom_suffix: String,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct VideoMetadata {
+ pub path: String,
+ pub size: u64,
+ pub format: String,
+ pub width: Option,
+ pub height: Option,
+ pub duration_secs: Option,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct VideoResult {
+ pub input: String,
+ pub output: Option,
+ pub original_size: u64,
+ pub output_size: u64,
+ pub error: Option,
+}
+
+#[derive(Debug, Clone, Serialize)]
+#[serde(rename_all = "camelCase")]
+struct VideoProgress {
+ index: usize,
+ total: usize,
+ file: String,
+ percent: Option,
+}
+
+struct PresetProfile {
+ crf_h264: u8,
+ crf_vp9: u8,
+ max_width: Option,
+}
+
+fn preset_profile(preset: &str) -> PresetProfile {
+ match preset.to_lowercase().as_str() {
+ "light" => PresetProfile {
+ crf_h264: 32,
+ crf_vp9: 36,
+ max_width: Some(1280),
+ },
+ "quality" => PresetProfile {
+ crf_h264: 23,
+ crf_vp9: 28,
+ max_width: None,
+ },
+ _ => PresetProfile {
+ crf_h264: 28,
+ crf_vp9: 32,
+ max_width: Some(1920),
+ },
+ }
+}
+
+fn normalize_format(format: &str) -> Result<&'static str, String> {
+ match format.to_lowercase().as_str() {
+ "mp4" => Ok("mp4"),
+ "webm" => Ok("webm"),
+ "mov" => Ok("mov"),
+ "mkv" => Ok("mkv"),
+ other => Err(format!("Unsupported output format: {other}")),
+ }
+}
+
+fn extension_of(path: &Path) -> String {
+ path.extension()
+ .and_then(|ext| ext.to_str())
+ .unwrap_or("")
+ .to_lowercase()
+}
+
+fn stem_of(path: &Path) -> String {
+ path.file_stem()
+ .and_then(|s| s.to_str())
+ .unwrap_or("video")
+ .to_string()
+}
+
+fn parent_folder(path: &Path) -> PathBuf {
+ path.parent()
+ .map(Path::to_path_buf)
+ .unwrap_or_else(|| PathBuf::from("."))
+}
+
+fn resolve_output_path(
+ input: &Path,
+ output_dir: &str,
+ format: &str,
+ naming: &str,
+ custom_suffix: &str,
+) -> PathBuf {
+ let dir = if output_dir.trim().is_empty() {
+ parent_folder(input)
+ } else {
+ PathBuf::from(output_dir)
+ };
+
+ let stem = stem_of(input);
+ let suffix = if naming == "replace" {
+ String::new()
+ } else if custom_suffix.trim().is_empty() {
+ DEFAULT_SUFFIX.to_string()
+ } else {
+ custom_suffix.trim().to_string()
+ };
+
+ let mut candidate = dir.join(format!("{stem}{suffix}.{format}"));
+ if candidate == input {
+ candidate = dir.join(format!("{stem}{DEFAULT_SUFFIX}.{format}"));
+ }
+ candidate
+}
+
+fn parse_duration_secs(stderr: &str) -> Option {
+ // Duration: 00:01:23.45
+ let marker = "Duration: ";
+ let start = stderr.find(marker)? + marker.len();
+ let slice = stderr.get(start..start + 11)?;
+ let parts: Vec<&str> = slice.split(':').collect();
+ if parts.len() != 3 {
+ return None;
+ }
+ let hours: f64 = parts[0].trim().parse().ok()?;
+ let minutes: f64 = parts[1].trim().parse().ok()?;
+ let seconds: f64 = parts[2].trim().parse().ok()?;
+ Some(hours * 3600.0 + minutes * 60.0 + seconds)
+}
+
+fn parse_video_dimensions(stderr: &str) -> (Option, Option) {
+ // Look for patterns like 1920x1080 in a Video: stream line
+ for line in stderr.lines() {
+ if !line.contains("Video:") {
+ continue;
+ }
+ let bytes = line.as_bytes();
+ let mut i = 0;
+ while i + 3 < bytes.len() {
+ if bytes[i].is_ascii_digit() {
+ let mut j = i;
+ while j < bytes.len() && bytes[j].is_ascii_digit() {
+ j += 1;
+ }
+ if j < bytes.len() && bytes[j] == b'x' {
+ let mut k = j + 1;
+ while k < bytes.len() && bytes[k].is_ascii_digit() {
+ k += 1;
+ }
+ if k > j + 1 {
+ if let (Ok(w), Ok(h)) = (
+ line[i..j].parse::(),
+ line[j + 1..k].parse::(),
+ ) {
+ if w >= 16 && h >= 16 && w <= 7680 && h <= 4320 {
+ return (Some(w), Some(h));
+ }
+ }
+ }
+ }
+ i = j;
+ } else {
+ i += 1;
+ }
+ }
+ }
+ (None, None)
+}
+
+fn parse_out_time_secs(line: &str) -> Option {
+ // progress pipe: out_time_ms=1234567 OR out_time=00:00:01.234456
+ if let Some(rest) = line.strip_prefix("out_time_ms=") {
+ let ms: f64 = rest.trim().parse().ok()?;
+ return Some(ms / 1_000_000.0);
+ }
+ if let Some(rest) = line.strip_prefix("out_time=") {
+ let value = rest.trim();
+ if value == "N/A" {
+ return None;
+ }
+ let parts: Vec<&str> = value.split(':').collect();
+ if parts.len() != 3 {
+ return None;
+ }
+ let hours: f64 = parts[0].parse().ok()?;
+ let minutes: f64 = parts[1].parse().ok()?;
+ let seconds: f64 = parts[2].parse().ok()?;
+ return Some(hours * 3600.0 + minutes * 60.0 + seconds);
+ }
+ None
+}
+
+async fn run_ffmpeg_capture(
+ app: &AppHandle,
+ args: Vec,
+) -> Result<(i32, String, String), String> {
+ let cmd = ffmpeg_command(app)?.args(args);
+ let (mut rx, _child) = cmd.spawn().map_err(|err| format!("Failed to spawn FFmpeg: {err}"))?;
+
+ let mut stdout = String::new();
+ let mut stderr = String::new();
+ let mut code = 1;
+
+ while let Some(event) = rx.recv().await {
+ match event {
+ CommandEvent::Stdout(line) => {
+ stdout.push_str(&String::from_utf8_lossy(&line));
+ stdout.push('\n');
+ }
+ CommandEvent::Stderr(line) => {
+ stderr.push_str(&String::from_utf8_lossy(&line));
+ stderr.push('\n');
+ }
+ CommandEvent::Terminated(payload) => {
+ code = payload.code.unwrap_or(1);
+ }
+ CommandEvent::Error(message) => {
+ return Err(format!("FFmpeg process error: {message}"));
+ }
+ _ => {}
+ }
+ }
+
+ Ok((code, stdout, stderr))
+}
+
+async fn probe_video(app: &AppHandle, path: &str) -> Result {
+ let size = std::fs::metadata(path)
+ .map(|meta| meta.len())
+ .unwrap_or(0);
+ let format = extension_of(Path::new(path));
+
+ let args = vec![
+ "-hide_banner".into(),
+ "-i".into(),
+ path.to_string(),
+ ];
+ let (_code, _stdout, stderr) = run_ffmpeg_capture(app, args).await?;
+ let (width, height) = parse_video_dimensions(&stderr);
+ let duration_secs = parse_duration_secs(&stderr);
+
+ Ok(VideoMetadata {
+ path: path.to_string(),
+ size,
+ format,
+ width,
+ height,
+ duration_secs,
+ })
+}
+
+fn build_encode_args(
+ input: &str,
+ output: &str,
+ format: &str,
+ preset: &str,
+) -> Vec {
+ let profile = preset_profile(preset);
+ let mut args = vec![
+ "-y".into(),
+ "-hide_banner".into(),
+ "-i".into(),
+ input.to_string(),
+ ];
+
+ if let Some(max_width) = profile.max_width {
+ args.extend([
+ "-vf".into(),
+ format!("scale='min({max_width},iw)':-2"),
+ ]);
+ }
+
+ match format {
+ "webm" => {
+ args.extend([
+ "-c:v".into(),
+ "libvpx-vp9".into(),
+ "-b:v".into(),
+ "0".into(),
+ "-crf".into(),
+ profile.crf_vp9.to_string(),
+ "-c:a".into(),
+ "libopus".into(),
+ "-b:a".into(),
+ "96k".into(),
+ ]);
+ }
+ _ => {
+ args.extend([
+ "-c:v".into(),
+ "libx264".into(),
+ "-preset".into(),
+ "medium".into(),
+ "-crf".into(),
+ profile.crf_h264.to_string(),
+ "-c:a".into(),
+ "aac".into(),
+ "-b:a".into(),
+ "128k".into(),
+ ]);
+ if format == "mp4" || format == "mov" {
+ args.extend(["-movflags".into(), "+faststart".into()]);
+ }
+ }
+ }
+
+ args.extend([
+ "-progress".into(),
+ "pipe:1".into(),
+ "-nostats".into(),
+ output.to_string(),
+ ]);
+ args
+}
+
+async fn encode_one(
+ app: &AppHandle,
+ input: &str,
+ options: &VideoOptions,
+ output_dir: &str,
+ index: usize,
+ total: usize,
+ duration_hint: Option,
+) -> VideoResult {
+ let original_size = std::fs::metadata(input).map(|m| m.len()).unwrap_or(0);
+ let format = match normalize_format(&options.output_format) {
+ Ok(fmt) => fmt,
+ Err(error) => {
+ return VideoResult {
+ input: input.to_string(),
+ output: None,
+ original_size,
+ output_size: 0,
+ error: Some(error),
+ };
+ }
+ };
+
+ let output_path = resolve_output_path(
+ Path::new(input),
+ output_dir,
+ format,
+ &options.output_naming,
+ &options.custom_suffix,
+ );
+
+ if let Some(parent) = output_path.parent() {
+ if let Err(error) = std::fs::create_dir_all(parent) {
+ return VideoResult {
+ input: input.to_string(),
+ output: None,
+ original_size,
+ output_size: 0,
+ error: Some(format!("Cannot create output folder: {error}")),
+ };
+ }
+ }
+
+ let output_str = output_path.to_string_lossy().to_string();
+ let file_label = Path::new(input)
+ .file_name()
+ .and_then(|n| n.to_str())
+ .unwrap_or(input)
+ .to_string();
+
+ let _ = app.emit(
+ "video:progress",
+ VideoProgress {
+ index,
+ total,
+ file: file_label.clone(),
+ percent: Some(0),
+ },
+ );
+
+ let args = build_encode_args(input, &output_str, format, &options.preset);
+ let cmd = match ffmpeg_command(app) {
+ Ok(cmd) => cmd.args(args),
+ Err(error) => {
+ return VideoResult {
+ input: input.to_string(),
+ output: None,
+ original_size,
+ output_size: 0,
+ error: Some(error),
+ };
+ }
+ };
+
+ let (mut rx, _child) = match cmd.spawn() {
+ Ok(pair) => pair,
+ Err(error) => {
+ return VideoResult {
+ input: input.to_string(),
+ output: None,
+ original_size,
+ output_size: 0,
+ error: Some(format!("Failed to spawn FFmpeg: {error}")),
+ };
+ }
+ };
+
+ let mut stderr = String::new();
+ let mut code = 1;
+ let mut last_percent: Option = Some(0);
+
+ while let Some(event) = rx.recv().await {
+ match event {
+ CommandEvent::Stdout(line) => {
+ let text = String::from_utf8_lossy(&line);
+ for part in text.split(['\n', '\r']) {
+ if let Some(secs) = parse_out_time_secs(part) {
+ if let Some(duration) = duration_hint.filter(|d| *d > 0.0) {
+ let percent = ((secs / duration) * 100.0).clamp(0.0, 99.0) as u32;
+ if last_percent != Some(percent) {
+ last_percent = Some(percent);
+ let _ = app.emit(
+ "video:progress",
+ VideoProgress {
+ index,
+ total,
+ file: file_label.clone(),
+ percent: Some(percent),
+ },
+ );
+ }
+ }
+ }
+ }
+ }
+ CommandEvent::Stderr(line) => {
+ stderr.push_str(&String::from_utf8_lossy(&line));
+ stderr.push('\n');
+ }
+ CommandEvent::Terminated(payload) => {
+ code = payload.code.unwrap_or(1);
+ }
+ CommandEvent::Error(message) => {
+ return VideoResult {
+ input: input.to_string(),
+ output: None,
+ original_size,
+ output_size: 0,
+ error: Some(format!("FFmpeg process error: {message}")),
+ };
+ }
+ _ => {}
+ }
+ }
+
+ if code != 0 {
+ let detail = stderr
+ .lines()
+ .rev()
+ .find(|line| !line.trim().is_empty())
+ .unwrap_or("FFmpeg failed")
+ .to_string();
+ return VideoResult {
+ input: input.to_string(),
+ output: None,
+ original_size,
+ output_size: 0,
+ error: Some(detail),
+ };
+ }
+
+ let output_size = std::fs::metadata(&output_path).map(|m| m.len()).unwrap_or(0);
+ let _ = app.emit(
+ "video:progress",
+ VideoProgress {
+ index,
+ total,
+ file: file_label,
+ percent: Some(100),
+ },
+ );
+
+ VideoResult {
+ input: input.to_string(),
+ output: Some(output_str),
+ original_size,
+ output_size,
+ error: None,
+ }
+}
+
+#[tauri::command]
+pub async fn get_videos_metadata(
+ app: AppHandle,
+ file_paths: Vec,
+) -> Result, String> {
+ let mut results = Vec::with_capacity(file_paths.len());
+ for path in file_paths {
+ match probe_video(&app, &path).await {
+ Ok(meta) => results.push(meta),
+ Err(_) => results.push(VideoMetadata {
+ path: path.clone(),
+ size: std::fs::metadata(&path).map(|m| m.len()).unwrap_or(0),
+ format: extension_of(Path::new(&path)),
+ width: None,
+ height: None,
+ duration_secs: None,
+ }),
+ }
+ }
+ Ok(results)
+}
+
+#[tauri::command]
+pub async fn process_videos(
+ app: AppHandle,
+ files: Vec,
+ options: VideoOptions,
+ output_dir: String,
+) -> Result, String> {
+ normalize_format(&options.output_format)?;
+
+ let total = files.len();
+ let mut results = Vec::with_capacity(total);
+
+ for (index, input) in files.into_iter().enumerate() {
+ let duration_hint = probe_video(&app, &input)
+ .await
+ .ok()
+ .and_then(|meta| meta.duration_secs);
+
+ let result = encode_one(
+ &app,
+ &input,
+ &options,
+ &output_dir,
+ index,
+ total,
+ duration_hint,
+ )
+ .await;
+ results.push(result);
+ }
+
+ Ok(results)
+}
diff --git a/src-tauri/src/ffmpeg.rs b/src-tauri/src/ffmpeg.rs
new file mode 100644
index 0000000..b719fb9
--- /dev/null
+++ b/src-tauri/src/ffmpeg.rs
@@ -0,0 +1,14 @@
+//! FFmpeg sidecar helpers. Binary is configured as `bundle.externalBin: ["binaries/ffmpeg"]`.
+
+use tauri::AppHandle;
+use tauri_plugin_shell::process::Command;
+use tauri_plugin_shell::ShellExt;
+
+/// Filename passed to `shell().sidecar(...)` (not the `binaries/` prefix).
+pub const FFMPEG_SIDECAR_NAME: &str = "ffmpeg";
+
+pub fn ffmpeg_command(app: &AppHandle) -> Result {
+ app.shell()
+ .sidecar(FFMPEG_SIDECAR_NAME)
+ .map_err(|err| format!("FFmpeg sidecar unavailable: {err}"))
+}
diff --git a/src-tauri/src/lib.rs b/src-tauri/src/lib.rs
index bd4c780..7656334 100644
--- a/src-tauri/src/lib.rs
+++ b/src-tauri/src/lib.rs
@@ -1,4 +1,5 @@
mod commands;
+mod ffmpeg;
use commands::*;
@@ -10,13 +11,16 @@ pub fn run() {
.plugin(tauri_plugin_opener::init())
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_dialog::init())
+ .plugin(tauri_plugin_shell::init())
.invoke_handler(tauri::generate_handler![
greet,
get_system_info,
convert_images,
generate_app_icons,
optimize_images,
- get_images_metadata
+ get_images_metadata,
+ get_videos_metadata,
+ process_videos
])
.run(tauri::generate_context!())
.expect("error while running tauri application");
diff --git a/src-tauri/tauri.conf.json b/src-tauri/tauri.conf.json
index 84fda88..7bee8b5 100644
--- a/src-tauri/tauri.conf.json
+++ b/src-tauri/tauri.conf.json
@@ -1,7 +1,7 @@
{
"$schema": "https://schema.tauri.app/config/2",
"productName": "PictoolsApp",
- "version": "0.3.5",
+ "version": "0.4.10",
"identifier": "com.onivoid.pictoolsapp",
"build": {
"beforeDevCommand": "pnpm dev",
@@ -35,6 +35,9 @@
"active": true,
"targets": "all",
"createUpdaterArtifacts": true,
+ "externalBin": [
+ "binaries/ffmpeg"
+ ],
"icon": [
"icons/32x32.png",
"icons/128x128.png",
diff --git a/src/ARCHITECTURE.md b/src/ARCHITECTURE.md
index 70c1585..a958a5e 100644
--- a/src/ARCHITECTURE.md
+++ b/src/ARCHITECTURE.md
@@ -15,7 +15,10 @@ src/
│
├── components/ # Reusable components
│ ├── ui/ # UI components (shadcn/ui)
-│ └── ... # Your custom components
+│ ├── workbench/ # Shared tool chrome (ToolWorkbench, FormatChip, FileQueue…)
+│ └── ... # Shell components (Sidebar, TopBar…)
+
+Design authority for agents: PRODUCT.md + DESIGN.md at the repo root (Impeccable).
│
├── composables/ # Custom hooks (Nuxt-style composables)
│ ├── useLocalStorage.ts # localStorage persistence
diff --git a/src/components/Sidebar.tsx b/src/components/Sidebar.tsx
index 536aab3..a35b671 100644
--- a/src/components/Sidebar.tsx
+++ b/src/components/Sidebar.tsx
@@ -1,7 +1,7 @@
import { useState } from "react";
import { useLocation, useNavigate } from "react-router-dom";
import { useTranslation } from "react-i18next";
-import { House, ImageIcon, Sparkles, Settings, PanelLeftClose, PanelLeftOpen } from "lucide-react";
+import { House, ImageIcon, Sparkles, Clapperboard, Settings, PanelLeftClose, PanelLeftOpen } from "lucide-react";
import { ROUTES } from "@/constants";
import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip";
import { motion, AnimatePresence } from "framer-motion";
@@ -104,6 +104,12 @@ export default function Sidebar() {
route: ROUTES.OPTIMIZE,
available: true,
},
+ {
+ icon: ,
+ label: t("video.title"),
+ route: ROUTES.VIDEO,
+ available: true,
+ },
];
const collapseBtn = (
diff --git a/src/components/workbench/FileQueue.tsx b/src/components/workbench/FileQueue.tsx
index 01cc22c..730ca07 100644
--- a/src/components/workbench/FileQueue.tsx
+++ b/src/components/workbench/FileQueue.tsx
@@ -1,5 +1,5 @@
import { convertFileSrc } from "@tauri-apps/api/core";
-import { AlertCircle, CheckCircle2, Loader2, Plus, X } from "lucide-react";
+import { AlertCircle, CheckCircle2, Film, Loader2, Plus, X } from "lucide-react";
import { formatBytes } from "@/utils/format";
export type QueueStatus = "pending" | "processing" | "done" | "error";
@@ -23,6 +23,7 @@ interface FileQueueProps {
disabled?: boolean;
onAdd?: () => void;
addLabel?: string;
+ media?: "image" | "video";
}
export function FileQueue({
@@ -33,6 +34,7 @@ export function FileQueue({
disabled = false,
onAdd,
addLabel,
+ media = "image",
}: FileQueueProps) {
if (files.length === 0) return null;
@@ -60,12 +62,27 @@ export function FileQueue({
}`}
>
-
})
+ {media === "video" ? (
+ <>
+
+
+
+
+ >
+ ) : (
+
})
+ )}
{file.status === "processing" && (
diff --git a/src/components/workbench/FormatChip.tsx b/src/components/workbench/FormatChip.tsx
new file mode 100644
index 0000000..875b9cb
--- /dev/null
+++ b/src/components/workbench/FormatChip.tsx
@@ -0,0 +1,43 @@
+import type { ButtonHTMLAttributes, ReactNode } from "react";
+import { cn } from "@/lib/utils";
+
+type FormatChipVariant = "default" | "accent";
+
+interface FormatChipProps extends ButtonHTMLAttributes
{
+ selected?: boolean;
+ variant?: FormatChipVariant;
+ children: ReactNode;
+}
+
+const base =
+ "px-2.5 py-1.5 rounded-md text-xs font-medium cursor-pointer transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-ring disabled:opacity-50 disabled:cursor-not-allowed";
+
+export function FormatChip({
+ selected = false,
+ variant = "default",
+ className,
+ children,
+ type = "button",
+ ...props
+}: FormatChipProps) {
+ const selectedClass =
+ variant === "accent"
+ ? "bg-primary/10 border border-primary text-primary"
+ : "bg-primary text-primary-foreground border border-transparent";
+
+ const idleClass =
+ variant === "accent"
+ ? "bg-background text-muted-foreground border border-border/60 hover:bg-accent hover:text-accent-foreground"
+ : "bg-background text-muted-foreground border border-border/60 hover:bg-accent hover:text-accent-foreground";
+
+ return (
+
+ );
+}
diff --git a/src/components/workbench/ToolWorkbench.tsx b/src/components/workbench/ToolWorkbench.tsx
index 3bb3944..e591179 100644
--- a/src/components/workbench/ToolWorkbench.tsx
+++ b/src/components/workbench/ToolWorkbench.tsx
@@ -1,10 +1,5 @@
import type { DragEvent, ReactNode, Ref } from "react";
-/* Hallmark · pre-emit critique: P4 H5 E4 S5 R5 V4
- * macrostructure: Stage+filmstrip · tone: utilitarian · theme: existing tokens
- * genre: modern-minimal · enrichment: none
- */
-
interface ToolWorkbenchProps {
icon: ReactNode;
title: string;
@@ -16,6 +11,8 @@ interface ToolWorkbenchProps {
draggingLabel?: string;
busy?: boolean;
busyLabel?: string;
+ /** 0–100 determinate progress under the busy label; omit for indeterminate. */
+ busyProgress?: number | null;
dropRef?: Ref;
onDragOver?: (event: DragEvent) => void;
onDragLeave?: (event: DragEvent) => void;
@@ -33,6 +30,7 @@ export function ToolWorkbench({
draggingLabel,
busy = false,
busyLabel,
+ busyProgress = null,
dropRef,
onDragOver,
onDragLeave,
@@ -58,10 +56,26 @@ export function ToolWorkbench({
{stage}
{busy && !isDragging && (
-
-
- {busyLabel}
-
+
+
+
+ {busyLabel}
+
+ {busyProgress != null && (
+
+ )}
+
)}
{isDragging && (
diff --git a/src/components/workbench/index.ts b/src/components/workbench/index.ts
index 65e6a46..c56615e 100644
--- a/src/components/workbench/index.ts
+++ b/src/components/workbench/index.ts
@@ -4,3 +4,4 @@ export { FileDropzone } from "./FileDropzone";
export { FileQueue } from "./FileQueue";
export type { QueueFile, QueueStatus } from "./FileQueue";
export { BeforeAfterCompare } from "./BeforeAfterCompare";
+export { FormatChip } from "./FormatChip";
diff --git a/src/composables/index.ts b/src/composables/index.ts
index 9e7e990..f2ec8b0 100644
--- a/src/composables/index.ts
+++ b/src/composables/index.ts
@@ -8,4 +8,6 @@ export { useLanguage } from "./useLanguage";
export { useUpdater } from "./useUpdater";
export { useImageDrop, loadImageEntries } from "./useImageDrop";
export type { ImageEntry, ImageMetadata, Orientation } from "./useImageDrop";
+export { useVideoDrop, loadVideoEntries } from "./useVideoDrop";
+export type { VideoEntry, VideoMetadata } from "./useVideoDrop";
export type { Language } from "./useLanguage";
diff --git a/src/composables/useVideoDrop.ts b/src/composables/useVideoDrop.ts
new file mode 100644
index 0000000..eb6eb09
--- /dev/null
+++ b/src/composables/useVideoDrop.ts
@@ -0,0 +1,122 @@
+import { useCallback, useEffect, useRef, useState, type DragEvent } from "react";
+import { invoke } from "@tauri-apps/api/core";
+import { open } from "@tauri-apps/plugin-dialog";
+import { getCurrentWindow } from "@tauri-apps/api/window";
+
+export interface VideoMetadata {
+ path: string;
+ size: number;
+ format: string;
+ width: number | null;
+ height: number | null;
+ durationSecs: number | null;
+}
+
+export interface VideoEntry {
+ path: string;
+ name: string;
+ size: number;
+ format: string;
+ width: number | null;
+ height: number | null;
+ durationSecs: number | null;
+}
+
+export async function loadVideoEntries(paths: string[]): Promise {
+ if (paths.length === 0) return [];
+
+ const items = await invoke("get_videos_metadata", { filePaths: paths });
+ const byPath = new Map(items.map((item) => [item.path, item]));
+
+ return paths.flatMap((path) => {
+ const metadata = byPath.get(path);
+ if (!metadata) return [];
+ return [
+ {
+ path,
+ name: path.split(/[\\/]/).pop() ?? path,
+ size: metadata.size,
+ format: metadata.format,
+ width: metadata.width,
+ height: metadata.height,
+ durationSecs: metadata.durationSecs,
+ },
+ ];
+ });
+}
+
+export function useVideoDrop(extensions: string[], onAdd: (paths: string[]) => void) {
+ const [isDragging, setIsDragging] = useState(false);
+ const dropRef = useRef(null);
+ const onAddRef = useRef(onAdd);
+ onAddRef.current = onAdd;
+
+ const filterPaths = useCallback(
+ (paths: string[]) =>
+ paths.filter((path) => {
+ const ext = path.split(".").pop()?.toLowerCase() ?? "";
+ return extensions.includes(ext);
+ }),
+ [extensions]
+ );
+
+ const handleBrowse = useCallback(async () => {
+ const selected = await open({
+ multiple: true,
+ filters: [{ name: "Videos", extensions }],
+ });
+ if (!selected) return;
+ const paths = Array.isArray(selected) ? selected : [selected];
+ const valid = filterPaths(paths);
+ if (valid.length) onAddRef.current(valid);
+ }, [extensions, filterPaths]);
+
+ useEffect(() => {
+ const win = getCurrentWindow();
+ let unlisten: (() => void) | undefined;
+
+ win
+ .onDragDropEvent((event) => {
+ if (event.payload.type === "drop") {
+ setIsDragging(false);
+ const paths: string[] = (event.payload as { paths?: string[] }).paths ?? [];
+ const valid = filterPaths(paths);
+ if (valid.length) onAddRef.current(valid);
+ } else if (event.payload.type === "enter" || event.payload.type === "over") {
+ setIsDragging(true);
+ } else if (event.payload.type === "leave") {
+ setIsDragging(false);
+ }
+ })
+ .then((fn) => {
+ unlisten = fn;
+ });
+
+ return () => {
+ unlisten?.();
+ };
+ }, [filterPaths]);
+
+ const handleDragOver = (event: DragEvent) => {
+ event.preventDefault();
+ setIsDragging(true);
+ };
+
+ const handleDragLeave = (event: DragEvent) => {
+ if (!dropRef.current?.contains(event.relatedTarget as Node)) setIsDragging(false);
+ };
+
+ const handleDrop = (event: DragEvent) => {
+ event.preventDefault();
+ setIsDragging(false);
+ };
+
+ return {
+ isDragging,
+ dropRef,
+ handleBrowse,
+ handleDragOver,
+ handleDragLeave,
+ handleDrop,
+ };
+}
diff --git a/src/constants/index.ts b/src/constants/index.ts
index b49d190..d902d51 100644
--- a/src/constants/index.ts
+++ b/src/constants/index.ts
@@ -5,6 +5,7 @@ export const ROUTES = {
HOME: "/",
CONVERT: "/convert",
OPTIMIZE: "/optimize",
+ VIDEO: "/video",
SETTINGS: "/settings",
} as const;
@@ -12,3 +13,33 @@ export const STORAGE_KEYS = {
THEME: "theme",
LANGUAGE: "language",
} as const;
+
+/** Common raster formats accepted by Convert / Optimize dropzones. */
+export const ACCEPTED_IMAGE_EXTENSIONS = [
+ "png",
+ "jpg",
+ "jpeg",
+ "webp",
+ "bmp",
+ "gif",
+ "tiff",
+ "tif",
+] as const;
+
+/** Convert also accepts ICO sources. */
+export const ACCEPTED_CONVERT_EXTENSIONS = [
+ ...ACCEPTED_IMAGE_EXTENSIONS,
+ "ico",
+] as const;
+
+/** Common video containers accepted by the Video tool. */
+export const ACCEPTED_VIDEO_EXTENSIONS = [
+ "mp4",
+ "mov",
+ "mkv",
+ "webm",
+ "avi",
+ "m4v",
+ "mpeg",
+ "mpg",
+] as const;
diff --git a/src/i18n/locales/en.json b/src/i18n/locales/en.json
index fbdc6ce..6634553 100644
--- a/src/i18n/locales/en.json
+++ b/src/i18n/locales/en.json
@@ -131,6 +131,58 @@
"compare": "Drag to compare"
}
},
+ "video": {
+ "title": "Video",
+ "subtitle": "Compress and convert videos — originals stay untouched",
+ "run": "Process videos",
+ "processing": "Working…",
+ "processingLabel": "Encoding {{file}} ({{percent}}%)",
+ "processingLabelIndeterminate": "Encoding {{file}}…",
+ "readingLabel": "Reading {{count}} video(s)…",
+ "dropzone": {
+ "idle": "Drop videos here, or browse to add them",
+ "dragging": "Release to add these videos",
+ "hint": "MP4, MOV, MKV, WebM, AVI, M4V · pick a preset and output format below",
+ "add": "Add videos",
+ "reading": "Reading {{count}} video(s)…"
+ },
+ "plan": {
+ "file": "{{count}} video ready",
+ "files": "{{count}} videos ready",
+ "suffix": "writes beside sources with a suffix",
+ "besideFiles": "saved next to the originals",
+ "besideMixed": "saved in each original folder",
+ "chooseFolder": "Choose output folder…",
+ "clearFolder": "Save next to originals instead"
+ },
+ "format": {
+ "label": "Output format"
+ },
+ "preset": {
+ "label": "Size vs quality",
+ "light": "Smaller",
+ "balanced": "Balanced",
+ "quality": "Higher quality",
+ "hint": {
+ "light": "Stronger compression. Width capped near 1280px.",
+ "balanced": "Default trade-off. Width capped near 1920px.",
+ "quality": "Gentler compression. Keeps the source resolution."
+ }
+ },
+ "output": {
+ "naming": "Output names",
+ "suffix": "Add a suffix",
+ "replace": "Same name in the output folder"
+ },
+ "meta": {
+ "unknownDims": "dimensions unknown"
+ },
+ "errors": {
+ "sidecar": "FFmpeg is missing from this build. Run scripts/fetch-ffmpeg.sh, then rebuild.",
+ "failed": "Couldn’t process this video. Try another format or preset.",
+ "generic": "Something went wrong while encoding."
+ }
+ },
"updater": {
"available": {
"title": "Update Available",
diff --git a/src/i18n/locales/fr.json b/src/i18n/locales/fr.json
index 589d419..fc0665a 100644
--- a/src/i18n/locales/fr.json
+++ b/src/i18n/locales/fr.json
@@ -131,6 +131,58 @@
"compare": "Glisser pour comparer"
}
},
+ "video": {
+ "title": "Vidéo",
+ "subtitle": "Compresser et convertir — les originaux restent intacts",
+ "run": "Traiter les vidéos",
+ "processing": "En cours…",
+ "processingLabel": "Encodage de {{file}} ({{percent}} %)",
+ "processingLabelIndeterminate": "Encodage de {{file}}…",
+ "readingLabel": "Lecture de {{count}} vidéo(s)…",
+ "dropzone": {
+ "idle": "Déposez des vidéos ici, ou parcourez pour les ajouter",
+ "dragging": "Relâchez pour ajouter ces vidéos",
+ "hint": "MP4, MOV, MKV, WebM, AVI, M4V · choisissez un preset et un format ci-dessous",
+ "add": "Ajouter des vidéos",
+ "reading": "Lecture de {{count}} vidéo(s)…"
+ },
+ "plan": {
+ "file": "{{count}} vidéo prête",
+ "files": "{{count}} vidéos prêtes",
+ "suffix": "écrit à côté des sources avec un suffixe",
+ "besideFiles": "enregistré à côté des originaux",
+ "besideMixed": "enregistré dans chaque dossier d’origine",
+ "chooseFolder": "Choisir un dossier de sortie…",
+ "clearFolder": "Enregistrer plutôt à côté des originaux"
+ },
+ "format": {
+ "label": "Format de sortie"
+ },
+ "preset": {
+ "label": "Poids vs qualité",
+ "light": "Plus léger",
+ "balanced": "Équilibré",
+ "quality": "Plus de qualité",
+ "hint": {
+ "light": "Compression plus forte. Largeur plafonnée vers 1280 px.",
+ "balanced": "Compromis par défaut. Largeur plafonnée vers 1920 px.",
+ "quality": "Compression plus douce. Conserve la résolution d’origine."
+ }
+ },
+ "output": {
+ "naming": "Noms de sortie",
+ "suffix": "Ajouter un suffixe",
+ "replace": "Même nom dans le dossier de sortie"
+ },
+ "meta": {
+ "unknownDims": "dimensions inconnues"
+ },
+ "errors": {
+ "sidecar": "FFmpeg manque dans ce build. Lancez scripts/fetch-ffmpeg.sh, puis reconstruisez.",
+ "failed": "Impossible de traiter cette vidéo. Essayez un autre format ou preset.",
+ "generic": "Une erreur est survenue pendant l’encodage."
+ }
+ },
"updater": {
"available": {
"title": "Mise à jour disponible",
diff --git a/src/index.css b/src/index.css
index ecd0066..1752f03 100644
--- a/src/index.css
+++ b/src/index.css
@@ -192,11 +192,6 @@
animation: page-in 0.25s cubic-bezier(0.16, 1, 0.3, 1) both;
}
-/* Hallmark · pre-emit critique: P4 H5 E4 S5 R5 V4
- * macrostructure: Stage+filmstrip · tone: utilitarian · theme: existing tokens
- * genre: modern-minimal · enrichment: none
- */
-
@media (prefers-reduced-motion: reduce) {
.page-enter {
animation: none;
diff --git a/src/pages/Convert.tsx b/src/pages/Convert.tsx
index c47c60e..8d376a5 100644
--- a/src/pages/Convert.tsx
+++ b/src/pages/Convert.tsx
@@ -9,11 +9,13 @@ import {
BeforeAfterCompare,
FileDropzone,
FileQueue,
+ FormatChip,
ToolDock,
ToolWorkbench,
type QueueFile,
} from "@/components/workbench";
import { loadImageEntries, useImageDrop } from "@/composables";
+import { ACCEPTED_CONVERT_EXTENSIONS } from "@/constants";
import { formatBytes } from "@/utils/format";
type TargetFormat = "png" | "jpeg" | "webp" | "ico" | "appicons";
@@ -37,7 +39,6 @@ interface AppIconsResult {
}
const ICO_SIZES = [16, 32, 48, 64, 128, 256];
-const ACCEPTED_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "bmp", "gif", "tiff", "tif", "ico"];
const FORMATS: { label: string; value: TargetFormat; special?: boolean }[] = [
{ label: "PNG", value: "png" },
{ label: "JPEG", value: "jpeg" },
@@ -107,7 +108,7 @@ export default function Convert() {
}, [files, selectedId]);
const { isDragging, dropRef, handleBrowse, handleDragOver, handleDragLeave, handleDrop } =
- useImageDrop(ACCEPTED_EXTENSIONS, addPaths);
+ useImageDrop([...ACCEPTED_CONVERT_EXTENSIONS], addPaths);
useEffect(() => {
let unlisten: (() => void) | undefined;
@@ -239,30 +240,21 @@ export default function Convert() {
const formatButtons = (
{FORMATS.filter((format) => !format.special).map((format) => (
-
+
))}
-
+
);
diff --git a/src/pages/Optimize.tsx b/src/pages/Optimize.tsx
index e1c1e20..0f461e5 100644
--- a/src/pages/Optimize.tsx
+++ b/src/pages/Optimize.tsx
@@ -8,11 +8,13 @@ import {
BeforeAfterCompare,
FileDropzone,
FileQueue,
+ FormatChip,
ToolDock,
ToolWorkbench,
type QueueFile,
} from "@/components/workbench";
import { loadImageEntries, useImageDrop, type Orientation } from "@/composables";
+import { ACCEPTED_IMAGE_EXTENSIONS } from "@/constants";
import { formatBytes } from "@/utils/format";
type OutputFormat = "png" | "jpeg" | "webp" | "original";
@@ -35,19 +37,12 @@ interface OptimizeResult {
error: string | null;
}
-const ACCEPTED_EXTENSIONS = ["png", "jpg", "jpeg", "webp", "bmp", "gif", "tiff", "tif"];
-
const WEB_CEILING_KIB: Record = {
landscape: 300,
portrait: 220,
square: 200,
};
-const CHIP =
- "py-1.5 px-2.5 rounded-md text-xs font-medium cursor-pointer transition-colors duration-150 focus-visible:outline-2 focus-visible:outline-ring";
-const CHIP_ON = "bg-primary text-primary-foreground";
-const CHIP_OFF = "bg-background text-muted-foreground hover:bg-accent hover:text-accent-foreground border border-border/60";
-
function parentFolder(path: string): string {
return path.replace(/[\\/][^\\/]+$/, "") || path;
}
@@ -141,7 +136,7 @@ export default function Optimize() {
}, [files, selectedId]);
const { isDragging, dropRef, handleBrowse, handleDragOver, handleDragLeave, handleDrop } =
- useImageDrop(ACCEPTED_EXTENSIONS, addPaths);
+ useImageDrop([...ACCEPTED_IMAGE_EXTENSIONS], addPaths);
const handleSelectOutputDir = async () => {
const dir = await open({ directory: true, multiple: false });
@@ -414,14 +409,13 @@ export default function Optimize() {
{(["webp", "jpeg", "png", "original"] as const).map((format) => (
-
+
))}
{useWebProfile && (
@@ -436,20 +430,18 @@ export default function Optimize() {
{t("optimize.output.naming")}
-
-
+
{outputNaming === "suffix" && (
string): string {
+ const lower = raw.toLowerCase();
+ if (
+ lower.includes("sidecar unavailable") ||
+ lower.includes("failed to spawn ffmpeg") ||
+ lower.includes("no such file")
+ ) {
+ return t("video.errors.sidecar");
+ }
+ if (lower.includes("ffmpeg")) {
+ return t("video.errors.failed");
+ }
+ return raw.trim() || t("video.errors.generic");
+}
+
+export default function Video() {
+ const { t } = useTranslation();
+ const [files, setFiles] = useState([]);
+ const [selectedId, setSelectedId] = useState(null);
+ const [outputFormat, setOutputFormat] = useState("mp4");
+ const [preset, setPreset] = useState("balanced");
+ const [outputNaming, setOutputNaming] = useState("suffix");
+ const [customSuffix, setCustomSuffix] = useState("_compressed");
+ const [outputDir, setOutputDir] = useState("");
+ const [isProcessing, setIsProcessing] = useState(false);
+ const [isDetecting, setIsDetecting] = useState(false);
+ const [detectCount, setDetectCount] = useState(0);
+ const [progressPercent, setProgressPercent] = useState(null);
+ const [progressFile, setProgressFile] = useState(null);
+
+ const selectedFile = files.find((file) => file.id === selectedId) ?? null;
+
+ const addPaths = useCallback(async (paths: string[]) => {
+ let toAdd: string[] = [];
+ setFiles((prev) => {
+ const existing = new Set(prev.map((file) => file.path));
+ toAdd = paths.filter((path) => !existing.has(path));
+ if (toAdd.length === 0) return prev;
+ const placeholders: VideoFile[] = toAdd.map((path) => ({
+ id: crypto.randomUUID(),
+ path,
+ name: fileNameFromPath(path),
+ status: "pending",
+ originalSize: 0,
+ format: "",
+ width: null,
+ height: null,
+ durationSecs: null,
+ }));
+ return [...prev, ...placeholders];
+ });
+ if (toAdd.length === 0) return;
+
+ setIsDetecting(true);
+ setDetectCount(toAdd.length);
+ try {
+ const entries = await loadVideoEntries(toAdd);
+ const byPath = new Map(entries.map((entry) => [entry.path, entry]));
+ setFiles((prev) =>
+ prev.flatMap((file) => {
+ if (!toAdd.includes(file.path)) return [file];
+ const entry = byPath.get(file.path);
+ if (!entry) return [];
+ return [
+ {
+ ...file,
+ originalSize: entry.size,
+ format: entry.format,
+ width: entry.width,
+ height: entry.height,
+ durationSecs: entry.durationSecs,
+ },
+ ];
+ })
+ );
+ } finally {
+ setIsDetecting(false);
+ }
+ }, []);
+
+ useEffect(() => {
+ if (!selectedId && files.length > 0) {
+ setSelectedId(files[0].id);
+ }
+ }, [files, selectedId]);
+
+ const { isDragging, dropRef, handleBrowse, handleDragOver, handleDragLeave, handleDrop } =
+ useVideoDrop([...ACCEPTED_VIDEO_EXTENSIONS], addPaths);
+
+ const handleSelectOutputDir = async () => {
+ const dir = await open({ directory: true, multiple: false });
+ if (dir && typeof dir === "string") setOutputDir(dir);
+ };
+
+ useEffect(() => {
+ let unlisten: (() => void) | undefined;
+ listen("video:progress", (event) => {
+ const { file, percent } = event.payload;
+ setProgressFile(file);
+ setProgressPercent(percent);
+ setFiles((prev) =>
+ prev.map((item) =>
+ item.name === file || item.path.endsWith(file)
+ ? { ...item, status: "processing" }
+ : item
+ )
+ );
+ }).then((fn) => {
+ unlisten = fn;
+ });
+ return () => unlisten?.();
+ }, []);
+
+ const options = useMemo(
+ () => ({
+ preset,
+ outputFormat,
+ outputNaming,
+ customSuffix,
+ }),
+ [preset, outputFormat, outputNaming, customSuffix]
+ );
+
+ const handleProcess = async () => {
+ if (!files.length || isDetecting) return;
+ setIsProcessing(true);
+ setProgressPercent(0);
+ setFiles((prev) => prev.map((file) => ({ ...file, status: "processing" as const })));
+
+ try {
+ const results = await invoke("process_videos", {
+ files: files.map((file) => file.path),
+ options,
+ outputDir,
+ });
+
+ setFiles((prev) =>
+ prev.map((file) => {
+ const result = results.find((item) => item.input === file.path);
+ if (!result) {
+ return { ...file, status: "error" as const, error: t("video.errors.generic") };
+ }
+ return {
+ ...file,
+ status: result.error ? "error" : "done",
+ originalSize: result.originalSize,
+ outputSize: result.outputSize,
+ outputPath: result.output ?? undefined,
+ error: result.error ? humanizeVideoError(result.error, t) : undefined,
+ };
+ })
+ );
+ } catch (error) {
+ const message = humanizeVideoError(String(error), t);
+ setFiles((prev) =>
+ prev.map((file) => ({ ...file, status: "error" as const, error: message }))
+ );
+ } finally {
+ setIsProcessing(false);
+ setProgressPercent(null);
+ setProgressFile(null);
+ }
+ };
+
+ const removeFile = (id: string) => {
+ setFiles((prev) => {
+ const next = prev.filter((file) => file.id !== id);
+ if (selectedId === id) setSelectedId(next[0]?.id ?? null);
+ return next;
+ });
+ };
+
+ const uniqueFolders = new Set(files.map((file) => parentFolder(file.path)));
+ const canProcess = files.length > 0 && !isProcessing && !isDetecting;
+ const empty = files.length === 0;
+ const hasDone = files.some((file) => file.status === "done");
+ const hasError = files.some((file) => file.status === "error") && !isProcessing;
+
+ const previewSrc = selectedFile
+ ? selectedFile.status === "done" && selectedFile.outputPath
+ ? convertFileSrc(selectedFile.outputPath)
+ : convertFileSrc(selectedFile.path)
+ : null;
+
+ const sizeLabel = selectedFile
+ ? selectedFile.outputSize != null
+ ? `${formatBytes(selectedFile.originalSize ?? 0)} → ${formatBytes(selectedFile.outputSize)}`
+ : selectedFile.originalSize
+ ? formatBytes(selectedFile.originalSize)
+ : null
+ : null;
+
+ const queueFiles = files.map((file) => {
+ const dims =
+ file.width && file.height ? `${file.width}×${file.height}` : t("video.meta.unknownDims");
+ const duration = formatDuration(file.durationSecs);
+ return {
+ ...file,
+ detail: `${dims} · ${duration}`,
+ };
+ });
+
+ const destination = outputDir
+ ? outputDir.split(/[\\/]/).pop()
+ : uniqueFolders.size > 1
+ ? t("video.plan.besideMixed")
+ : t("video.plan.besideFiles");
+
+ return (
+ }
+ title={t("video.title")}
+ subtitle={t("video.subtitle")}
+ isDragging={isDragging}
+ draggingLabel={t("video.dropzone.dragging")}
+ busy={isDetecting || isProcessing}
+ busyLabel={
+ isProcessing
+ ? progressPercent != null
+ ? t("video.processingLabel", {
+ file: progressFile ?? "",
+ percent: progressPercent,
+ })
+ : t("video.processingLabelIndeterminate", {
+ file: progressFile ?? "",
+ })
+ : t("video.readingLabel", { count: detectCount })
+ }
+ busyProgress={isProcessing ? progressPercent : null}
+ dropRef={dropRef}
+ onDragOver={handleDragOver}
+ onDragLeave={handleDragLeave}
+ onDrop={handleDrop}
+ stage={
+ empty ? (
+
+ ) : (
+
+ {selectedFile?.status === "error" && selectedFile.error ? (
+
+ {selectedFile.error}
+
+ ) : null}
+ {previewSrc ? (
+
+ ) : null}
+ {sizeLabel && selectedFile?.status !== "error" && (
+
+ {sizeLabel}
+
+ )}
+
+ )
+ }
+ dock={
+ empty ? undefined : (
+
+
+ {t(files.length === 1 ? "video.plan.file" : "video.plan.files", {
+ count: files.length,
+ })}
+ {` · ${t(`video.preset.${preset}`)} · ${outputFormat.toUpperCase()}`}
+
+
+ {t("video.plan.suffix")} · {destination}
+
+
+
+ }
+ primary={
+
+ }
+ advancedOpen
+ advanced={
+
+
+
+ {t("video.format.label")}
+
+
+ {(["mp4", "webm", "mov", "mkv"] as const).map((format) => (
+ setOutputFormat(format)}
+ >
+ {format.toUpperCase()}
+
+ ))}
+
+
+
+
+
+ {t("video.preset.label")}
+
+
+ {(["light", "balanced", "quality"] as const).map((value) => (
+ setPreset(value)}
+ >
+ {t(`video.preset.${value}`)}
+
+ ))}
+
+
+ {t(`video.preset.hint.${preset}`)}
+
+
+
+
+
+ }
+ />
+ )
+ }
+ strip={
+ empty ? undefined : (
+
+ )
+ }
+ />
+ );
+}
diff --git a/src/router/index.tsx b/src/router/index.tsx
index 2487758..591c174 100644
--- a/src/router/index.tsx
+++ b/src/router/index.tsx
@@ -3,6 +3,7 @@ import RootLayout from "@/layouts/RootLayout";
import Home from "@/pages/Home";
import Convert from "@/pages/Convert";
import Optimize from "@/pages/Optimize";
+import Video from "@/pages/Video";
import Settings from "@/pages/Settings";
export const router = createMemoryRouter([
@@ -22,6 +23,10 @@ export const router = createMemoryRouter([
path: "optimize",
element:
,
},
+ {
+ path: "video",
+ element:
,
+ },
{
path: "settings",
element:
,