mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 03:33:14 +01:00
Offset modified date to respect the frame offset (#55)
This commit is contained in:
parent
8b62183501
commit
8b54a7cc2d
@ -27,7 +27,8 @@ async function captureFrame(customOutDir, filePath, video, currentTime, captureF
|
||||
|
||||
const outPath = util.getOutPath(customOutDir, filePath, `${time}.${ext}`);
|
||||
await fs.writeFileAsync(outPath, buf);
|
||||
return util.transferTimestamps(filePath, outPath);
|
||||
const offset = -video.duration + currentTime;
|
||||
return util.transferTimestampsWithOffset(filePath, outPath, offset);
|
||||
}
|
||||
|
||||
module.exports = captureFrame;
|
||||
|
11
src/util.js
11
src/util.js
@ -33,8 +33,19 @@ async function transferTimestamps(inPath, outPath) {
|
||||
}
|
||||
}
|
||||
|
||||
async function transferTimestampsWithOffset(inPath, outPath, offset) {
|
||||
try {
|
||||
const stat = await fs.statAsync(inPath);
|
||||
const time = (stat.mtime.getTime() / 1000) + offset;
|
||||
await fs.utimesAsync(outPath, time, time);
|
||||
} catch (err) {
|
||||
console.error('Failed to set output file modified time', err);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
formatDuration,
|
||||
getOutPath,
|
||||
transferTimestamps,
|
||||
transferTimestampsWithOffset,
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user