Skip to content

The swiss army knife of lossless video/audio editing

offset mtime/atime by currentTime

Mikael Finstad5704713a061f
diff --git a/src/App.jsx b/src/App.jsx
index bc7170f2..ef15d438 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -1096,22 +1096,22 @@ const App = memo(() => {
}, [working, filePath, haveInvalidSegs, outSegments, exportConfirmEnabled, onExportConfirm]);
const capture = useCallback(async () => {
- if (!filePath || !isDurationValid(duration)) return;
+ if (!filePath) return;
try {
const mustCaptureFfmpeg = html5FriendlyPath || dummyVideoPath;
const currentTime = currentTimeRef.current;
const video = videoRef.current;
const outPath = mustCaptureFfmpeg
- ? await captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat, duration })
- : await captureFrameFromTag({ customOutDir, filePath, currentTime, captureFormat, duration, video });
+ ? await captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat })
+ : await captureFrameFromTag({ customOutDir, filePath, currentTime, captureFormat, video });
openDirToast({ dirPath: outputDir, text: `${i18n.t('Screenshot captured to:')} ${outPath}` });
} catch (err) {
console.error(err);
errorToast(i18n.t('Failed to capture frame'));
}
- }, [filePath, captureFormat, customOutDir, html5FriendlyPath, dummyVideoPath, outputDir, duration]);
+ }, [filePath, captureFormat, customOutDir, html5FriendlyPath, dummyVideoPath, outputDir]);
const changePlaybackRate = useCallback((dir) => {
if (canvasPlayerEnabled) {
diff --git a/src/capture-frame.js b/src/capture-frame.js
index 67d656d0..8da24dc6 100644
--- a/src/capture-frame.js
+++ b/src/capture-frame.js
@@ -19,21 +19,16 @@ function getFrameFromVideo(video, format) {
return strongDataUri.decode(dataUri);
}
-async function transferTimestampsWithTime({ duration, currentTime, fromPath, toPath }) {
- const offset = -duration + currentTime;
- await transferTimestamps(fromPath, toPath, offset);
-}
-
-export async function captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat, duration }) {
+export async function captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat }) {
const time = formatDuration({ seconds: currentTime, fileNameFriendly: true });
const outPath = getOutPath(customOutDir, filePath, `${time}.${captureFormat}`);
await ffmpegCaptureFrame({ timestamp: currentTime, videoPath: filePath, outPath });
- await transferTimestampsWithTime({ duration, currentTime, fromPath: filePath, toPath: outPath });
+ await transferTimestamps(filePath, outPath, currentTime);
return outPath;
}
-export async function captureFrameFromTag({ customOutDir, filePath, currentTime, captureFormat, duration, video }) {
+export async function captureFrameFromTag({ customOutDir, filePath, currentTime, captureFormat, video }) {
const buf = getFrameFromVideo(video, captureFormat);
const ext = mime.extension(buf.mimetype);
@@ -42,6 +37,6 @@ export async function captureFrameFromTag({ customOutDir, filePath, currentTime,
const outPath = getOutPath(customOutDir, filePath, `${time}.${ext}`);
await fs.writeFile(outPath, buf);
- await transferTimestampsWithTime({ duration, currentTime, fromPath: filePath, toPath: outPath });
+ await transferTimestamps(filePath, outPath, currentTime);
return outPath;
}