From 682b09483498749bc3a7234dae8fc2bd8dcc3a17 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 3 Oct 2026 15:53:14 +0000 Subject: [PATCH] Default to full-size frames, resample at high quality, enlarge the preview Co-Authored-By: Claude Sonnet 5.5 Claude-Session: https://claude.ai/code/session_01DdY8xusG6G8nPf9mY5XQqv --- src/app/extractor.ts | 2 ++ src/lib/scale.ts | 2 +- src/styles.css | 4 ++-- test/dedupe.test.ts | 2 +- test/extractor.test.ts | 6 ++++++ test/helpers/fakes.ts | 1 + 6 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/app/extractor.ts b/src/app/extractor.ts index 73695dd..b067146 100644 --- a/src/app/extractor.ts +++ b/src/app/extractor.ts @@ -201,6 +201,7 @@ export async function seekTo( export interface Canvas2dLike { imageSmoothingEnabled: boolean; + imageSmoothingQuality?: 'low' | 'medium' | 'high'; drawImage(source: never, dx: number, dy: number, dw: number, dh: number): void; /** Draws only the [sx,sy,sw,sh] source rectangle — how a crop gets applied. */ drawImage( @@ -298,6 +299,7 @@ export function createCanvasRenderer(options: RendererOptions): FrameRenderer { if (!ctx) throw new Error('Canvas 2D context unavailable'); ctx.imageSmoothingEnabled = true; + ctx.imageSmoothingQuality = 'high'; ctx.clearRect(0, 0, size.width, size.height); if (crop) { ctx.drawImage(video as never, crop.x, crop.y, crop.width, crop.height, 0, 0, size.width, size.height); diff --git a/src/lib/scale.ts b/src/lib/scale.ts index d7c18b0..0181a1b 100644 --- a/src/lib/scale.ts +++ b/src/lib/scale.ts @@ -13,7 +13,7 @@ export const SIZE_PRESETS = [ { value: 720, label: '720' }, ] as const; -export const DEFAULT_MAX_EDGE = 1920; +export const DEFAULT_MAX_EDGE = 0; /** * Scale `source` down so its longest edge is at most `maxEdge`, preserving diff --git a/src/styles.css b/src/styles.css index e1500f0..8a5f8fb 100644 --- a/src/styles.css +++ b/src/styles.css @@ -281,7 +281,7 @@ main { .stage__video { width: 100%; /* Cap so a portrait clip can't push the controls off-screen. */ - max-height: 46dvh; + max-height: 52dvh; object-fit: contain; background: #000; } @@ -920,7 +920,7 @@ main { } .stage__video { - max-height: 52dvh; + max-height: 58dvh; } } diff --git a/test/dedupe.test.ts b/test/dedupe.test.ts index ad1250c..0dbebad 100644 --- a/test/dedupe.test.ts +++ b/test/dedupe.test.ts @@ -12,7 +12,7 @@ import { import { createSettings } from '../src/lib/settings.js'; import { MAX_FPS } from '../src/lib/time.js'; -const SIG = 'jpeg:1.00:1920:none'; +const SIG = 'jpeg:1.00:0:none'; function grab(time: number, overrides: Partial = {}): GrabIdentity { return { videoKey: 'clip', time, signature: SIG, ...overrides }; diff --git a/test/extractor.test.ts b/test/extractor.test.ts index e165152..3d688ee 100644 --- a/test/extractor.test.ts +++ b/test/extractor.test.ts @@ -219,6 +219,12 @@ describe('createCanvasRenderer', () => { expect(size).toEqual({ width: 1280, height: 720 }); }); + it('resamples at high quality', async () => { + const canvas = new FakeCanvas(); + await makeRenderer(canvas, 1280).render(new FakeVideo({ videoWidth: 3840, videoHeight: 2160 })); + expect(canvas.context.imageSmoothingQuality).toBe('high'); + }); + it('omits quality for lossless formats', async () => { const canvas = new FakeCanvas(); const renderer = createCanvasRenderer({ diff --git a/test/helpers/fakes.ts b/test/helpers/fakes.ts index 0a3b640..1f874e4 100644 --- a/test/helpers/fakes.ts +++ b/test/helpers/fakes.ts @@ -84,6 +84,7 @@ function grayImage(width: number, height: number): RGBAImage { export class FakeContext implements Canvas2dLike { imageSmoothingEnabled = false; + imageSmoothingQuality: 'low' | 'medium' | 'high' = 'low'; readonly draws: DrawCall[] = []; readonly clears: Array<{ w: number; h: number }> = []; /** Override to control what getImageData() returns for detection tests. */