Skip to content

The swiss army knife of lossless video/audio editing

Feature media: hero demo for the homepage, higher quality masters

Claude6d4b995829d0
diff --git a/script/featureMedia.ts b/script/featureMedia.ts
index 2bc3a691..77b57877 100644
--- a/script/featureMedia.ts
+++ b/script/featureMedia.ts
@@ -91,6 +91,8 @@ try {
// Lossless while recording, re-encoded below
const recorder = execa(ffmpeg, ['-v', 'error', ...grab, '-c:v', 'libx264', '-preset', 'ultrafast', '-qp', '0', rawVideo], { reject: false, stderr: 'inherit' });
+ const recordingStarted = performance.now();
+ let videoStart = 0;
await timers.setTimeout(500);
const action = async (name: string, args?: unknown) => {
@@ -129,6 +131,9 @@ try {
await execa(ffmpeg, ['-v', 'error', '-y', ...grab, '-frames:v', '1', join(outDir, `${scenarioName}-${name}.png`)]);
},
wait: async (ms) => timers.setTimeout(ms),
+ startVideo: () => {
+ videoStart = (performance.now() - recordingStarted) / 1000;
+ },
});
} finally {
// ffmpeg finishes the file and exits (with code 255) on SIGINT
@@ -136,9 +141,9 @@ try {
}
const { exitCode } = await recorder;
assert(exitCode === 0 || exitCode === 255, `Recording failed with exit code ${exitCode}`);
- // Small file for posting: x264 at a quality that keeps UI text sharp, and the index at the start for streaming
+ // A high quality master (web versions are made from it elsewhere), with the index at the start for streaming
const videoPath = join(outDir, `${scenarioName}.mp4`);
- await execa(ffmpeg, ['-v', 'error', '-y', '-i', rawVideo, '-c:v', 'libx264', '-preset', 'slow', '-crf', '24', '-tune', 'animation', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', videoPath]);
+ await execa(ffmpeg, ['-v', 'error', '-y', '-ss', String(videoStart), '-i', rawVideo, '-c:v', 'libx264', '-preset', 'slow', '-crf', '18', '-tune', 'animation', '-pix_fmt', 'yuv420p', '-movflags', '+faststart', videoPath]);
console.log('Wrote', videoPath, 'and screenshots in', outDir);
} finally {
app.kill();
diff --git a/script/featureMedia/scenarios.ts b/script/featureMedia/scenarios.ts
index cfe41603..302ed484 100644
--- a/script/featureMedia/scenarios.ts
+++ b/script/featureMedia/scenarios.ts
@@ -5,6 +5,35 @@
import type { Scenario } from './types.ts';
const scenarios: Record<string, Scenario> = {
+ // For the website's homepage: a short silent loop of the core idea. Keep it quick, and don't use clips that need a credit
+ hero: {
+ description: 'Keep the good parts and get a new file in seconds',
+ clips: ['DJI_0759.MP4'],
+ config: { autoMerge: true, exportConfirmEnabled: false },
+ async run({ open, action, actionWithDialog, shot, wait, startVideo }) {
+ await open('DJI_0759.MP4');
+ // Wait until the thumbnails are loaded, so the loop starts on the opened file
+ await wait(4000);
+ startVideo();
+ await shot('opened');
+ await wait(1500);
+ for (const [start, end, label] of [['00:00:02', '00:00:05', 'Sea'], ['00:00:10', '00:00:13', 'Cliffs'], ['00:00:18', '00:00:22', 'Sunset']] as const) {
+ await action('goToTimecodeDirect', { time: start });
+ await action('setCutStart');
+ await wait(400);
+ await action('goToTimecodeDirect', { time: end });
+ await action('setCutEnd');
+ // Give the app time to update the segment, or the label would be set on the old one
+ await wait(300);
+ await actionWithDialog('labelCurrentSegment', label);
+ await wait(600);
+ }
+ await shot('segments');
+ await action('export');
+ await wait(2500);
+ await shot('exported');
+ },
+ },
'cut-segments': {
description: 'Mark and label two segments to keep, play them and export',
clips: ['DJI_0759.MP4'],
diff --git a/script/featureMedia/types.ts b/script/featureMedia/types.ts
index 7dffe6ec..2eb355f7 100644
--- a/script/featureMedia/types.ts
+++ b/script/featureMedia/types.ts
@@ -14,6 +14,8 @@ export interface ScenarioContext {
/** Saves a screenshot as <scenario>-<name>.png */
shot: (name: string) => Promise<void>,
wait: (ms: number) => Promise<void>,
+ /** Starts the video here instead of at the beginning, e.g. after opening the file */
+ startVideo: () => void,
}
export interface Scenario {