Skip to content

The swiss army knife of lossless video/audio editing

show indicator when export/capture is done 🎉

Mikael Finstad250507452816
diff --git a/package.json b/package.json
index f3da20bc..8bfb2579 100644
--- a/package.json
+++ b/package.json
@@ -48,6 +48,7 @@
"@tsconfig/node20": "^20.1.4",
"@tsconfig/strictest": "^2.0.2",
"@tsconfig/vite-react": "^3.0.0",
+ "@types/canvas-confetti": "^1",
"@types/color": "^3.0.6",
"@types/css-modules": "^1.0.5",
"@types/eslint": "^8",
@@ -70,6 +71,7 @@
"@typescript-eslint/parser": "^6.12.0",
"@uidotdev/usehooks": "^2.4.1",
"@vitejs/plugin-react": "^4.3.4",
+ "canvas-confetti": "^1.9.3",
"color": "^3.1.0",
"concurrently": "^6.0.0",
"csv-parse": "^5.6.0",
diff --git a/src/renderer/src/App.tsx b/src/renderer/src/App.tsx
index 0bc8c9a3..71653db1 100644
--- a/src/renderer/src/App.tsx
+++ b/src/renderer/src/App.tsx
@@ -74,6 +74,7 @@ import {
getDownloadMediaOutPath,
isAbortedError,
withErrorHandling,
+ shootConfetti,
} from './util';
import { toast, errorToast, showPlaybackFailedMessage } from './swal';
import { adjustRate } from './util/rate-calculator';
@@ -1182,6 +1183,8 @@ function App() {
openExportFinishedToast({ filePath: revealPath, warnings, notices });
}
+ shootConfetti({ ticks: 50 });
+
if (cleanupChoices.cleanupAfterExport) await cleanupFilesWithDialog();
setExportCount((c) => c + 1);
@@ -1230,19 +1233,26 @@ function App() {
const captureSnapshot = useCallback(async () => {
if (!filePath) return;
+ if (workingRef.current) return;
+ try {
+ setWorking({ text: i18n.t('Exporting') });
- await withErrorHandling(async () => {
- const currentTime = getRelevantTime();
- const video = videoRef.current;
- if (video == null) throw new Error();
- const usingFfmpeg = usingPreviewFile || captureFrameMethod === 'ffmpeg';
- const outPath = usingFfmpeg
- ? await captureFrameFromFfmpeg({ customOutDir, filePath, time: currentTime, captureFormat, quality: captureFrameQuality })
- : await captureFrameFromTag({ customOutDir, filePath, time: currentTime, captureFormat, quality: captureFrameQuality, video });
-
- if (!hideAllNotifications) openDirToast({ icon: 'success', filePath: outPath, text: `${i18n.t('Screenshot captured to:')} ${outPath}` });
- }, i18n.t('Failed to capture frame'));
- }, [filePath, getRelevantTime, videoRef, usingPreviewFile, captureFrameMethod, captureFrameFromFfmpeg, customOutDir, captureFormat, captureFrameQuality, captureFrameFromTag, hideAllNotifications]);
+ await withErrorHandling(async () => {
+ const currentTime = getRelevantTime();
+ const video = videoRef.current;
+ if (video == null) throw new Error();
+ const usingFfmpeg = usingPreviewFile || captureFrameMethod === 'ffmpeg';
+ const outPath = usingFfmpeg
+ ? await captureFrameFromFfmpeg({ customOutDir, filePath, time: currentTime, captureFormat, quality: captureFrameQuality })
+ : await captureFrameFromTag({ customOutDir, filePath, time: currentTime, captureFormat, quality: captureFrameQuality, video });
+
+ shootConfetti();
+ if (!hideAllNotifications) openDirToast({ icon: 'success', filePath: outPath, text: `${i18n.t('Screenshot captured to:')} ${outPath}` });
+ }, i18n.t('Failed to capture frame'));
+ } finally {
+ setWorking(undefined);
+ }
+ }, [filePath, workingRef, setWorking, getRelevantTime, videoRef, usingPreviewFile, captureFrameMethod, captureFrameFromFfmpeg, customOutDir, captureFormat, captureFrameQuality, captureFrameFromTag, hideAllNotifications]);
const extractSegmentsFramesAsImages = useCallback(async (segments: SegmentBase[]) => {
if (!filePath || detectedFps == null || workingRef.current || segments.length === 0) return;
diff --git a/src/renderer/src/util.ts b/src/renderer/src/util.ts
index c663bf8b..417e569e 100644
--- a/src/renderer/src/util.ts
+++ b/src/renderer/src/util.ts
@@ -5,6 +5,7 @@ import prettyBytes from 'pretty-bytes';
import sortBy from 'lodash/sortBy';
import pRetry, { Options } from 'p-retry';
import { ExecaError } from 'execa';
+import confetti from 'canvas-confetti';
import isDev from './isDev';
import Swal, { errorToast, toast } from './swal';
@@ -527,3 +528,20 @@ export const calcShouldShowKeyframes = (zoomedDuration: number | undefined) => (
export const mediaSourceQualities = ['HD', 'SD', 'OG']; // OG is original
export const splitKeyboardKeys = (keys: string) => keys.split('+');
+
+export function shootConfetti(options?: confetti.Options) {
+ confetti({
+ particleCount: 30,
+ angle: 110,
+ startVelocity: 30,
+ spread: 40,
+ ticks: 25,
+ disableForReducedMotion: true,
+ origin: {
+ x: 0.98,
+ // since they fall down, start a bit higher than random
+ y: 1.03,
+ },
+ ...options,
+ });
+}
diff --git a/yarn.lock b/yarn.lock
index 340e790d..8486fb6f 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -1954,6 +1954,13 @@ __metadata:
languageName: node
linkType: hard
+"@types/canvas-confetti@npm:^1":
+ version: 1.9.0
+ resolution: "@types/canvas-confetti@npm:1.9.0"
+ checksum: 10/7c7423972465d21fc70a7842091735c51875bb7b4466bb623f11462de247272497c5e4a668aad6033e4bf5be3aaf0b57b059c9b26ac02592f4e02df423b86982
+ languageName: node
+ linkType: hard
+
"@types/color-convert@npm:*":
version: 2.0.3
resolution: "@types/color-convert@npm:2.0.3"
@@ -3471,6 +3478,13 @@ __metadata:
languageName: node
linkType: hard
+"canvas-confetti@npm:^1.9.3":
+ version: 1.9.3
+ resolution: "canvas-confetti@npm:1.9.3"
+ checksum: 10/50378c45a10030f0e6c5d2e93972d6e01170dd197b74ef150dcc2ef0166c8e3eb600ea0e930cf923143be6ae4c7ff15ccf74fb6c347a177e6aa4de966afcb610
+ languageName: node
+ linkType: hard
+
"chai@npm:^5.2.0":
version: 5.2.0
resolution: "chai@npm:5.2.0"
@@ -7692,6 +7706,7 @@ __metadata:
"@tsconfig/node20": "npm:^20.1.4"
"@tsconfig/strictest": "npm:^2.0.2"
"@tsconfig/vite-react": "npm:^3.0.0"
+ "@types/canvas-confetti": "npm:^1"
"@types/color": "npm:^3.0.6"
"@types/css-modules": "npm:^1.0.5"
"@types/eslint": "npm:^8"
@@ -7714,6 +7729,7 @@ __metadata:
"@typescript-eslint/parser": "npm:^6.12.0"
"@uidotdev/usehooks": "npm:^2.4.1"
"@vitejs/plugin-react": "npm:^4.3.4"
+ canvas-confetti: "npm:^1.9.3"
color: "npm:^3.1.0"
concurrently: "npm:^6.0.0"
csv-parse: "npm:^5.6.0"