Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/app/extractor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/lib/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -920,7 +920,7 @@ main {
}

.stage__video {
max-height: 52dvh;
max-height: 58dvh;
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/dedupe.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> = {}): GrabIdentity {
return { videoKey: 'clip', time, signature: SIG, ...overrides };
Expand Down
6 changes: 6 additions & 0 deletions test/extractor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down
1 change: 1 addition & 0 deletions test/helpers/fakes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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. */
Expand Down
Loading