1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00

Offset modified date to respect the frame offset (#55)

This commit is contained in:
Erik Fonselius 2018-02-11 14:09:01 +01:00 committed by Mikael Finstad
parent 8b62183501
commit 8b54a7cc2d
2 changed files with 13 additions and 1 deletions

View File

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

View File

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