Choose size, rate and what follows when recording the editor

The editor recording had fixed settings: the canvas size at 60 fps,
always converted and imported. Recording in 4K needs a choice, and the
server shrank every video to 1080p anyway. Start recording... now opens
a dialog, and a recording always goes to the server as it is.

- The dialog holds name, resolution (Screen, 1080p, 1440p, 4K), fps
  (60 or 30), mouse pointer, sound, Convert and Import after
  conversion. Import is greyed out while Convert is off. The browser
  keeps the last choice, not the name.
- A larger resolution makes the editor draw finer while it records,
  so 4K is sharp, not stretched. It is never below the screen's own
  resolution and goes back after Stop.
- Stop always uploads. Without Convert the file only stays on the
  server. Without Import it is converted but no asset is added. Both
  are found in the video picker.
- The server keeps the original next to each MP4 for every upload, so
  Download in the video tab and the picker gives the original. Videos
  from before have none, they still download their MP4.
- A file left unconverted shows in the picker as not converted, with
  a Convert button. POST videos/{file}/convert queues it, and upload
  takes convert=0.
- The worker now caps a video at 3840x2160 instead of 1920x1080. Videos
  converted before stay as they are.

Tests:
- PHP videos.test.php: 81 checks green, with the original, convert=0,
  a later Convert and the 4K cap.
- Unit recording: 5 new, green. Red without the rule that a recording
  is never below the screen's resolution.
- e2e 67e-ii: the video tab downloads the .source.mkv, a Matroska
  file. 67f: 1440p from a 1280x800 window gives 2304x1440 at 30 fps
  without sound, kept and not imported, then converted in the picker.
  Both red with the MP4 download and without the finer drawing.
- The README names 2045 e2e checks.
- Gate on melektaus-atx: 304 files, 4699 tests green.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
adminandClaude Opus 5.5 committed 2026-10-12 17:01:55 +02:00
1 parent 93190e185c
commit ba01d146e9
26 files changed
+1011 -129

No files matched your search

+1 -1
View File
@@ -61,7 +61,7 @@ export async function topbar(t) {
'Master routing',
'Clear saved data',
null,
'Start recording',
'Start recording…',
null,
'General settings…',
'Plugins',
+123 -7
View File
@@ -1,4 +1,4 @@
import { MAKE_OBJECT } from './lib/scaffold.mjs';
import { MAKE_OBJECT, pickAssetType } from './lib/scaffold.mjs';
/**
* Recording the game view (#405). A behavior starts a recording at 1080p and 30 fps when the run
@@ -177,10 +177,30 @@ export async function recording(t) {
// 67e. The editor records itself from the main menu: the whole canvas at 60 fps, the mouse pointer
// drawn in where the system draws it over the canvas, and the red dot beside the menu on
// screen only. The frame is read where the pointer rested on the empty middle of the top bar.
const { mouse, cdp, clickToolbar, clickText } = t;
await clickToolbar('menu');
const idle = await json('__gm.menuRows()');
await clickText('Start recording');
const { mouse, cdp, click, clickToolbar, clickText } = t;
// Downloads are caught rather than saved: what counts is which file and under which name.
await evaluate(`window.__downloads = [];
HTMLAnchorElement.prototype.click = function () { window.__downloads.push({ name: this.download, href: this.href }); };`);
const startDialog = async (change) => {
await clickToolbar('menu');
const rows = await json('__gm.menuRows()');
await clickText('Start recording…');
await waitUntil('__gm.recordingDialog() !== null', { label: 'the recording dialog opens' });
await evaluate(`__gm.recordingDialogChoose(${JSON.stringify(change)})`);
return rows;
};
const DEFAULTS = {
name: '',
resolution: 'screen',
fps: 60,
pointer: true,
sound: true,
convert: true,
adopt: true,
};
const idle = await startDialog(DEFAULTS);
const start = (await json('__gm.recordingDialog()')).start;
await click(start.x, start.y);
await waitUntil(`__gm.recording().editor.takes[0]?.state === 'recording'`, { label: 'the editor records' });
const redo = await json('__gm.toolbarAt("redo")');
const playAt = await json('__gm.toolbarAt("play")');
@@ -289,8 +309,8 @@ export async function recording(t) {
}).length
: -1;
check(
'Start recording in the main menu records the whole editor at 60 fps with the pointer drawn in, the red dot on screen only, and Stop recording saves it',
idle.includes('Start recording') &&
'Start recording… in the main menu records the whole editor at 60 fps with the pointer drawn in, the red dot on screen only, and Stop recording saves it',
idle.includes('Start recording…') &&
busy.includes('Stop recording') &&
take.width === canvas.w - (canvas.w % 2) &&
take.height === canvas.h - (canvas.h % 2) &&
@@ -327,6 +347,102 @@ export async function recording(t) {
}),
);
// 67e-ii. The video tab's Download saves the recording as it was recorded – the Matroska file the
// editor uploaded, kept beside the MP4 the server made of it.
const firstBytes = (href) =>
evaluate(
`fetch(${JSON.stringify(href)}).then((r) => r.arrayBuffer()).then((b) => [...new Uint8Array(b.slice(0, 4))].map((v) => v.toString(16).padStart(2, '0')).join(''))`,
);
await evaluate(`__gm.openDocument(${JSON.stringify(`asset:${upload.assetId}`)})`);
await waitUntil(`__gm.videoTab.current() === ${JSON.stringify(upload.assetId)}`, {
label: 'the recording opens in the video tab',
});
const downloadAt = await json('__gm.videoTab.downloadButton()');
await click(downloadAt.x, downloadAt.y);
await waitUntil('__gm.videoTab.lastDownload() !== null', { label: 'the video tab downloads' });
const tabDownload = await json('__gm.videoTab.lastDownload()');
const tabHead = await firstBytes(tabDownload.href);
check(
"the video tab's Download saves the recording as it was recorded, not the MP4",
tabDownload.href === `/game-maker/data/videos/${file.replace(/\.mp4$/, '.source.mkv')}` &&
tabDownload.name === `${take.name}.mkv` &&
(await json('window.__downloads')).some((d) => d.name === tabDownload.name) &&
tabHead === '1a45dfa3',
JSON.stringify({ tabDownload, tabHead, file }),
);
// 67f. "Start recording…" with its options. 1440p from the 1280×800 window is drawn sharper while
// it records (resolution 1.8) rather than scaled up, here at 30 fps without sound. Without
// Convert, Import goes grey, the file is only kept on the server and nothing comes into the
// project. The video picker downloads it as it is, and converts it on asking at its full size,
// above the 1080p the server used to shrink every video to.
const assetsBefore = await json('__gm.state.project.assets.length');
await startDialog({ resolution: '1440p', fps: 30, pointer: false, sound: false });
const convertAt = (await json('__gm.recordingDialog()')).switches.convert;
await click(convertAt.x, convertAt.y);
const asked = await json('__gm.recordingDialog()');
await click(asked.start.x, asked.start.y);
await waitUntil(`__gm.recording().editor.takes[1]?.state === 'recording'`, {
label: 'the second editor take records',
});
const raised = (await json('__gm.recording().editor')).resolution;
await sleep(1000);
await clickToolbar('menu');
await clickText('Stop recording');
await waitUntil(`__gm.recording().editor.takes[1]?.state === 'done'`, {
label: 'the second editor take is saved',
});
const sharp = (await json('__gm.recording().editor')).takes[1];
const back = (await json('__gm.recording().editor')).resolution;
await waitUntil(
`__gm.recording().uploads.some((u) => u.name === ${JSON.stringify(sharp.name)} && (u.state === 'kept' || u.state === 'failed'))`,
{ timeout: 60_000, label: 'the second editor recording is uploaded' },
);
const kept = (await recordings()).uploads.find((u) => u.name === sharp.name);
await showTab('scene');
await clickText('+');
await pickAssetType(t, 'Video');
await waitUntil(`__gm.videoPicker()?.files.includes(${JSON.stringify(kept.file)})`, {
label: 'the picker lists the kept recording',
});
const keptRow = await json(`__gm.videoPickerRow(${JSON.stringify(kept.file)})`);
await click(keptRow.x, keptRow.y);
const keptPick = await json('__gm.videoPicker()');
const [pickerDownload, pickerConvert] = keptPick.extras;
await click(pickerDownload.x, pickerDownload.y);
const pickerSaved = (await json('__gm.videoPicker()')).lastDownload;
const pickerHead = pickerSaved ? await firstBytes(pickerSaved.href) : '';
await click(pickerConvert.x, pickerConvert.y);
await waitUntil(`__gm.videoPicker()?.detail.includes('2304 × 1440')`, {
timeout: 60_000,
label: 'the kept recording is converted on asking',
});
const converted = await json('__gm.videoPicker()');
await press('Escape');
check(
'Start recording… records 1440p sharper at 30 fps without sound; without Convert it is only kept, the picker downloads it as it is and converts it on asking',
asked.adoptEnabled === false &&
asked.values.convert === false &&
asked.size === '2304 × 1440 at 30 fps, from this window' &&
raised === 1.8 &&
back === 1 &&
sharp.width === 2304 &&
sharp.height === 1440 &&
sharp.fps === 30 &&
sharp.sound === false &&
kept.state === 'kept' &&
keptPick.detail.includes('Not converted') &&
pickerDownload.enabled &&
pickerConvert.enabled &&
pickerSaved?.name === `${sharp.name}.mkv` &&
pickerSaved.href === `/game-maker/data/videos/${kept.file.replace(/\.mp4$/, '.source.mkv')}` &&
pickerHead === '1a45dfa3' &&
converted.detail.includes('2304 × 1440') &&
converted.extras[1].enabled === false &&
(await json('__gm.state.project.assets.length')) === assetsBefore,
JSON.stringify({ asked, raised, back, sharp, kept, keptPick, pickerSaved, pickerHead, converted }),
);
await mutate(`
const p = __gm.state.project;
const made = ${JSON.stringify([...assets.map((a) => a.id), upload.assetId])};