1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-23 02:42:37 +01:00
This commit is contained in:
Mikael Finstad 2020-11-22 23:40:50 +01:00
parent 40694fe738
commit e2d219b51c
2 changed files with 8 additions and 8 deletions

View File

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

View File

@ -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, curre
const 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;
}