offset mtime/atime by currentTime

I think it's more normal for mtime to be start of recording
pull/699/head
Mikael Finstad 5 years ago
parent 62f99a5e7e
commit 5704713a06
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -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) {

@ -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;
}

Loading…
Cancel
Save