Skip to content

The swiss army knife of lossless video/audio editing

Feature media: merge cuts and fixed duration segments demos

Claudea5d16aaa4375
diff --git a/script/featureMedia.ts b/script/featureMedia.ts
index 6123e1b0..77a46083 100644
--- a/script/featureMedia.ts
+++ b/script/featureMedia.ts
@@ -44,7 +44,7 @@ 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-'));
// 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] }));
+await writeFile(join(configDir, 'config.json'), JSON.stringify({ windowBounds: { x: 0, y: 0, width, height }, allowMultipleInstances: true, autoSaveProjectFile: false, enableCustomOutDir: true, recentCustomOutDirs: [configDir], ...scenario.config }));
// 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`);
diff --git a/script/featureMedia/scenarios.ts b/script/featureMedia/scenarios.ts
index e5cd7270..714509dc 100644
--- a/script/featureMedia/scenarios.ts
+++ b/script/featureMedia/scenarios.ts
@@ -188,6 +188,49 @@ const scenarios: Record<string, Scenario> = {
await shot('inverted');
},
},
+ 'merge-cuts': {
+ description: 'Cut out three parts and merge them into one file',
+ clips: ['DJI_0759.MP4'],
+ config: { autoMerge: true },
+ async run({ open, action, shot, wait }) {
+ await open('DJI_0759.MP4');
+ await wait(2000);
+ for (const [start, end] of [['00:00:02', '00:00:05'], ['00:00:10', '00:00:13'], ['00:00:18', '00:00:22']]) {
+ await action('goToTimecodeDirect', { time: start });
+ await action('setCutStart');
+ await action('goToTimecodeDirect', { time: end });
+ await action('setCutEnd');
+ await wait(1000);
+ }
+ await shot('segments');
+ // Shows the export confirmation (with "Merge cuts"), then exports
+ await action('export');
+ await wait(2500);
+ await shot('export');
+ await action('export');
+ await wait(4000);
+ await shot('exported');
+ },
+ },
+ 'fixed-duration-segments': {
+ description: 'Split a video into 5 second parts, e.g. for stories',
+ clips: ['DJI_0759.MP4'],
+ async run({ open, action, key, type, shot, wait }) {
+ await open('DJI_0759.MP4');
+ await wait(2000);
+ // Opens a dialog asking for the duration
+ const creating = action('createFixedDurationSegments');
+ await wait(1500);
+ await key('ctrl+a');
+ await type('00:00:05');
+ await wait(800);
+ await shot('dialog');
+ await key('Return');
+ await creating;
+ await wait(2000);
+ await shot('segments');
+ },
+ },
};
export default scenarios;
diff --git a/script/featureMedia/types.ts b/script/featureMedia/types.ts
index 0045562a..65d11d21 100644
--- a/script/featureMedia/types.ts
+++ b/script/featureMedia/types.ts
@@ -18,5 +18,7 @@ export interface Scenario {
description: string,
/** File names of the clips it needs, from the clips folder or downloaded */
clips: string[],
+ /** Settings to start with (see src/main/configStore.ts), e.g. to show an export mode */
+ config?: Record<string, unknown>,
run: (ctx: ScenarioContext) => Promise<void>,
}