The swiss army knife of lossless video/audio editing
Feature media: tracks, scene change, waveform, rotate and invert demos
Claude3f53dba195e1
diff --git a/AGENTS.md b/AGENTS.mdindex 390afd48..ea14b1e5 100644--- a/AGENTS.md+++ b/AGENTS.md@@ -30,9 +30,10 @@ Never submit to a store, publish a release or post an announcement without the u```bashyarn build && yarn download-ffmpeg-linux-x64+# If missing: apt-get install xvfb xdotoolxvfb-run -a -s "-screen 0 1280x800x24" node script/featureMedia.ts cut-segments```-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.+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. `tears-of-steel.mkv` is a 45 s excerpt (00:20–01:05) of [Tears of Steel](https://mango.blender.org/) with its stereo and 5.1 mixes and 6 subtitle tracks. It's CC BY 3.0, so posts that show it must credit "Tears of Steel (CC) Blender Foundation | mango.blender.org". 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.tsindex 99010027..dfd5b75e 100644--- a/script/featureMedia.ts+++ b/script/featureMedia.ts@@ -84,6 +84,9 @@ try {console.log('Action', name, args ?? '');await post(`action/${name}`, args);},+ key: async (keys) => {+ await execa('xdotool', ['key', keys]);+ },shot: async (name) => {await execa(ffmpeg, ['-v', 'error', '-y', ...grab, '-frames:v', '1', join(outDir, `${scenarioName}-${name}.png`)]);},diff --git a/script/featureMedia/scenarios.ts b/script/featureMedia/scenarios.tsindex da6731d4..1d812a06 100644--- a/script/featureMedia/scenarios.ts+++ b/script/featureMedia/scenarios.ts@@ -63,6 +63,80 @@ const scenarios: Record<string, Scenario> = {await shot('merge');},},+ tracks: {+ description: 'Show the tracks of a file with several audio and subtitle tracks',+ clips: ['tears-of-steel.mkv'],+ async run({ open, action, shot, wait }) {+ await open('tears-of-steel.mkv');+ await wait(3000);+ await action('toggleStreamsSelector');+ await wait(3000);+ await shot('tracks');+ },+ },+ 'detect-scene-changes': {+ description: 'Create segments from the scene changes',+ clips: ['tears-of-steel.mkv'],+ async run({ open, action, key, shot, wait }) {+ await open('tears-of-steel.mkv');+ await wait(3000);+ // Opens a parameters dialog, confirm it with the defaults+ const detecting = action('detectSceneChanges');+ await wait(2000);+ await shot('parameters');+ await key('Return');+ await detecting;+ await wait(5000);+ await shot('segments');+ },+ },+ waveform: {+ description: 'Show the audio waveform while playing',+ clips: ['tears-of-steel.mkv'],+ async run({ open, action, shot, wait }) {+ await open('tears-of-steel.mkv');+ await wait(3000);+ await action('toggleWaveformMode');+ await action('goToTimecodeDirect', { time: '00:00:03' });+ await action('play');+ await wait(8000);+ await action('pause');+ await shot('waveform');+ },+ },+ rotate: {+ description: 'Rotate a video losslessly',+ clips: ['DJI_0740.MP4'],+ async run({ open, action, shot, wait }) {+ await open('DJI_0740.MP4');+ await wait(2000);+ await shot('original');+ // The first press sets 0° (to override the file's rotation), the next one 90°+ await action('increaseRotation');+ await action('increaseRotation');+ await wait(5000);+ await shot('rotated');+ },+ },+ 'invert-segments': {+ description: 'Mark the parts to remove, then invert to keep the rest',+ clips: ['DJI_0759.MP4'],+ async run({ open, action, shot, wait }) {+ await open('DJI_0759.MP4');+ await wait(2000);+ for (const [start, end] of [['00:00:05', '00:00:09'], ['00:00:16', '00:00:19']]) {+ await action('goToTimecodeDirect', { time: start });+ await action('setCutStart');+ await action('goToTimecodeDirect', { time: end });+ await action('setCutEnd');+ await wait(1000);+ }+ await shot('marked');+ await action('invertAllSegments');+ await wait(2000);+ await shot('inverted');+ },+ },};export default scenarios;diff --git a/script/featureMedia/types.ts b/script/featureMedia/types.tsindex b8ab63b8..e0a2108c 100644--- a/script/featureMedia/types.ts+++ b/script/featureMedia/types.ts@@ -3,6 +3,8 @@ export interface ScenarioContext {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>,+ /** Presses keys with xdotool, e.g. 'Return' to confirm a dialog that an action opened (start the action without awaiting it) */+ key: (keys: string) => Promise<void>,/** Saves a screenshot as <scenario>-<name>.png */shot: (name: string) => Promise<void>,wait: (ms: number) => Promise<void>,