pull/508/head
Mikael Finstad 6 years ago
parent 40694fe738
commit e2d219b51c

@ -1038,8 +1038,8 @@ const App = memo(() => {
const currentTime = currentTimeRef.current; const currentTime = currentTimeRef.current;
const video = videoRef.current; const video = videoRef.current;
const outPath = mustCaptureFfmpeg const outPath = mustCaptureFfmpeg
? await captureFrameFfmpeg({ customOutDir, videoPath: filePath, currentTime, captureFormat, duration }) ? await captureFrameFfmpeg({ customOutDir, filePath, currentTime, captureFormat, duration })
: await captureFrameFromTag({ customOutDir, filePath, video, currentTime, captureFormat }); : await captureFrameFromTag({ customOutDir, filePath, currentTime, captureFormat, duration, video });
openDirToast({ dirPath: outputDir, text: `${i18n.t('Screenshot captured to:')} ${outPath}` }); openDirToast({ dirPath: outputDir, text: `${i18n.t('Screenshot captured to:')} ${outPath}` });
} catch (err) { } catch (err) {

@ -24,16 +24,16 @@ async function transferTimestamps({ duration, currentTime, fromPath, toPath }) {
await transferTimestampsWithOffset(fromPath, toPath, offset); 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 time = formatDuration({ seconds: currentTime, fileNameFriendly: true });
const outPath = getOutPath(customOutDir, videoPath, `${time}.${captureFormat}`); const outPath = getOutPath(customOutDir, filePath, `${time}.${captureFormat}`);
await ffmpegCaptureFrame({ timestamp: currentTime, videoPath, outPath }); await ffmpegCaptureFrame({ timestamp: currentTime, videoPath: filePath, outPath });
await transferTimestamps({ duration, currentTime, fromPath: videoPath, toPath: outPath }); await transferTimestamps({ duration, currentTime, fromPath: filePath, toPath: outPath });
return 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 buf = getFrameFromVideo(video, captureFormat);
const ext = mime.extension(buf.mimetype); const ext = mime.extension(buf.mimetype);
@ -42,6 +42,6 @@ export async function captureFrameFromTag({ customOutDir, filePath, video, curre
const outPath = getOutPath(customOutDir, filePath, `${time}.${ext}`); const outPath = getOutPath(customOutDir, filePath, `${time}.${ext}`);
await fs.writeFile(outPath, buf); 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; return outPath;
} }

Loading…
Cancel
Save