The swiss army knife of lossless video/audio editing
refactor
Mikael Finstade2d219b51cba
diff --git a/src/App.jsx b/src/App.jsxindex 88b2b1c4..f994ce67 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -1038,8 +1038,8 @@ const App = memo(() => {const currentTime = currentTimeRef.current;const video = videoRef.current;const outPath = mustCaptureFfmpeg- ? await captureFrameFfmpeg({ customOutDir, videoPath: filePath, currentTime, captureFormat, duration })- : await captureFrameFromTag({ customOutDir, filePath, video, currentTime, captureFormat });+ ? await captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat, duration })+ : await captureFrameFromTag({ customOutDir, filePath, currentTime, captureFormat, duration, video });openDirToast({ dirPath: outputDir, text: `${i18n.t('Screenshot captured to:')} ${outPath}` });} catch (err) {diff --git a/src/capture-frame.js b/src/capture-frame.jsindex 39caae17..f6edff7f 100644--- a/src/capture-frame.js+++ b/src/capture-frame.js@@ -24,16 +24,16 @@ async function transferTimestamps({ duration, currentTime, fromPath, toPath }) {await transferTimestampsWithOffset(fromPath, toPath, offset);}-export async function captureFrameFfmpeg({ customOutDir, videoPath, currentTime, captureFormat, duration }) {+export async function captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat, duration }) {const time = formatDuration({ seconds: currentTime, fileNameFriendly: true });- const outPath = getOutPath(customOutDir, videoPath, `${time}.${captureFormat}`);- await ffmpegCaptureFrame({ timestamp: currentTime, videoPath, outPath });- await transferTimestamps({ duration, currentTime, fromPath: videoPath, toPath: outPath });+ const outPath = getOutPath(customOutDir, filePath, `${time}.${captureFormat}`);+ await ffmpegCaptureFrame({ timestamp: currentTime, videoPath: filePath, outPath });+ await transferTimestamps({ duration, currentTime, fromPath: filePath, toPath: outPath });return outPath;}-export async function captureFrameFromTag({ customOutDir, filePath, video, currentTime, captureFormat }) {+export async function captureFrameFromTag({ customOutDir, filePath, currentTime, captureFormat, duration, video }) {const buf = getFrameFromVideo(video, captureFormat);const ext = mime.extension(buf.mimetype);@@ -42,6 +42,6 @@ export async function captureFrameFromTag({ customOutDir, filePath, video, curreconst outPath = getOutPath(customOutDir, filePath, `${time}.${ext}`);await fs.writeFile(outPath, buf);- await transferTimestamps({ duration: video.duration, currentTime, fromPath: filePath, toPath: outPath });+ await transferTimestamps({ duration, currentTime, fromPath: filePath, toPath: outPath });return outPath;}