Skip to content

The swiss army knife of lossless video/audio editing

Feature media: demos with clips from static.mifi.no

Claudec5ecfd6e0203
diff --git a/AGENTS.md b/AGENTS.md
index a714ce41..390afd48 100644
--- a/AGENTS.md
+++ b/AGENTS.md
@@ -33,6 +33,6 @@ yarn build && yarn download-ffmpeg-linux-x64
xvfb-run -a -s "-screen 0 1280x800x24" node script/featureMedia.ts cut-segments
```
-The clips come from `dist/feature-media-clips`, or are downloaded from `FEATURE_MEDIA_CLIPS_URL`. The results go to `dist/feature-media`. Failed actions don't fail the script, so look at the screenshots (and `<scenario>-app.log`) to check that the demo did what it should. Never commit clips or results.
+The clips come from `dist/feature-media-clips`, or are downloaded from https://static.mifi.no/losslesscut (or `FEATURE_MEDIA_CLIPS_URL`; behind a proxy, e.g. in a cloud session, set `NODE_USE_ENV_PROXY=1`). Scenarios can use only the clips there; ask the user to upload new ones. The results go to `dist/feature-media`. Failed actions don't fail the script, so look at the screenshots (and `<scenario>-app.log`) to check that the demo did what it should. Never commit clips or results.
When a user-visible feature lands on master, suggest adding a scenario for it and recording it.
diff --git a/script/featureMedia.ts b/script/featureMedia.ts
index 6aa68f27..99010027 100644
--- a/script/featureMedia.ts
+++ b/script/featureMedia.ts
@@ -27,12 +27,11 @@ const outDir = 'dist/feature-media';
await mkdir(outDir, { recursive: true });
await mkdir(clips, { recursive: true });
-// Get the clips, from the folder or else from FEATURE_MEDIA_CLIPS_URL
-const clipsUrl = process.env['FEATURE_MEDIA_CLIPS_URL'];
+// Get the clips, from the folder or else download them
+const clipsUrl = process.env['FEATURE_MEDIA_CLIPS_URL'] ?? 'https://static.mifi.no/losslesscut';
for (const clip of scenario.clips) {
const path = join(clips, clip);
if (!await access(path).then(() => true, () => false)) {
- assert(clipsUrl != null, `${path} is missing. Put it there, or set FEATURE_MEDIA_CLIPS_URL to download it`);
console.log('Downloading', clip);
const response = await fetch(`${clipsUrl}/${clip}`);
assert(response.ok && response.body != null, `Failed to download ${clip}: ${response.status}`);
@@ -44,7 +43,8 @@ for (const clip of scenario.clips) {
// A fresh config, so the demo doesn't depend on (or change) your own settings, doesn't hand over to your running LosslessCut, and saves no project file next to the clip (it would be loaded next time)
const configDir = await mkdtemp(join(tmpdir(), 'losslesscut-feature-media-'));
-await writeFile(join(configDir, 'config.json'), JSON.stringify({ windowBounds: { x: 0, y: 0, width, height }, allowMultipleInstances: true, autoSaveProjectFile: false }));
+// Exports go to the temp dir too
+await writeFile(join(configDir, 'config.json'), JSON.stringify({ windowBounds: { x: 0, y: 0, width, height }, allowMultipleInstances: true, autoSaveProjectFile: false, enableCustomOutDir: true, recentCustomOutDirs: [configDir] }));
// The app's log, including the renderer's console. Failed actions don't fail the HTTP request, so check the screenshots and this log
const appLog = join(outDir, `${scenarioName}-app.log`);
@@ -79,7 +79,7 @@ try {
try {
await scenario.run({
- open: async (clip) => post('action/openFiles', [resolve(clips, clip)]),
+ open: async (...names) => post('action/openFiles', names.map((name) => resolve(clips, name))),
action: async (name, args) => {
console.log('Action', name, args ?? '');
await post(`action/${name}`, args);
diff --git a/script/featureMedia/scenarios.ts b/script/featureMedia/scenarios.ts
index fa630078..da6731d4 100644
--- a/script/featureMedia/scenarios.ts
+++ b/script/featureMedia/scenarios.ts
@@ -5,14 +5,14 @@ import type { Scenario } from './types.ts';
const scenarios: Record<string, Scenario> = {
'cut-segments': {
- description: 'Open a file and mark two segments to keep',
- clips: ['demo.mp4'],
+ description: 'Mark two segments to keep, play them and export',
+ clips: ['DJI_0759.MP4'],
async run({ open, action, shot, wait }) {
- await open('demo.mp4');
+ await open('DJI_0759.MP4');
await wait(2000);
await shot('opened');
// Setting a start after the last segment starts a new segment
- for (const [start, end] of [['00:00:02', '00:00:05'], ['00:00:09', '00:00:13']]) {
+ for (const [start, end] of [['00:00:03', '00:00:08'], ['00:00:14', '00:00:20']]) {
await action('goToTimecodeDirect', { time: start });
await action('setCutStart');
await wait(700);
@@ -20,10 +20,49 @@ const scenarios: Record<string, Scenario> = {
await action('setCutEnd');
await wait(1000);
}
+ await shot('segments');
+ await action('togglePlaySelectedSegments');
+ await wait(12000);
+ await action('pause');
+ // Shows the export confirmation, then exports
+ await action('export');
+ await wait(2000);
+ await shot('export');
+ await action('export');
+ await wait(3000);
+ await shot('exported');
+ },
+ },
+ 'split-segments': {
+ description: 'Split the video into segments while it plays',
+ clips: ['DJI_0740.MP4'],
+ async run({ open, action, shot, wait }) {
+ await open('DJI_0740.MP4');
+ await wait(2000);
+ await action('play');
+ for (let i = 0; i < 4; i += 1) {
+ await wait(2500);
+ await action('splitCurrentSegment');
+ }
+ await action('pause');
await wait(1500);
await shot('segments');
},
},
+ 'merge-files': {
+ description: 'Open several files and merge them into one',
+ clips: ['DJI_0009.MOV', 'DJI_0121.MOV', 'DJI_0740.MP4', 'DJI_0759.MP4'],
+ async run({ open, action, shot, wait }) {
+ await open('DJI_0009.MOV', 'DJI_0121.MOV', 'DJI_0740.MP4', 'DJI_0759.MP4');
+ await wait(1500);
+ await action('batchOpenSelectedFile');
+ await wait(2000);
+ await shot('batch');
+ await action('concatBatch');
+ await wait(3000);
+ await shot('merge');
+ },
+ },
};
export default scenarios;
diff --git a/script/featureMedia/types.ts b/script/featureMedia/types.ts
index fb899c94..b8ab63b8 100644
--- a/script/featureMedia/types.ts
+++ b/script/featureMedia/types.ts
@@ -1,6 +1,6 @@
export interface ScenarioContext {
- /** Opens a clip from the clips folder */
- open: (clip: string) => Promise<void>,
+ /** Opens clips from the clips folder (several go to the batch list) */
+ open: (...clips: string[]) => Promise<void>,
/** Runs a keyboard action (see the Keyboard & mouse shortcuts dialog for names), optionally with arguments */
action: (name: string, args?: unknown) => Promise<void>,
/** Saves a screenshot as <scenario>-<name>.png */
@@ -10,7 +10,7 @@ export interface ScenarioContext {
export interface Scenario {
description: string,
- /** File names of the clips it needs, from the clips folder or downloaded from FEATURE_MEDIA_CLIPS_URL */
+ /** File names of the clips it needs, from the clips folder or downloaded */
clips: string[],
run: (ctx: ScenarioContext) => Promise<void>,
}