1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-25 03:33:14 +01:00

rename option

This commit is contained in:
nieve 2024-08-30 22:15:22 -04:00
parent 7d55abb5fc
commit fafbe91e3f
3 changed files with 10 additions and 10 deletions

View File

@ -329,9 +329,9 @@ export async function askForAlignSegments() {
nearest: i18n.t('Nearest keyframe'),
before: i18n.t('Previous keyframe'),
after: i18n.t('Next keyframe'),
consistent: i18n.t('True keyframe cut'),
keyframeCutFix: i18n.t('True keyframe cut'),
},
inputValue: 'consistent',
inputValue: 'keyframeCutFix',
text: i18n.t('Do you want to align segment times to the nearest, previous or next keyframe?'),
});

View File

@ -106,7 +106,7 @@ export const findNextKeyframe = (keyframes: Keyframe[], time: number) => keyfram
const findPreviousKeyframe = (keyframes: Keyframe[], time: number) => keyframes.findLast((keyframe) => keyframe.time <= time);
const findNearestKeyframe = (keyframes: Keyframe[], time: number) => minBy(keyframes, (keyframe) => Math.abs(keyframe.time - time));
export type FindKeyframeMode = 'nearest' | 'before' | 'after' | 'consistent';
export type FindKeyframeMode = 'nearest' | 'before' | 'after' | 'keyframeCutFix';
function findKeyframe(keyframes: Keyframe[], time: number, mode: FindKeyframeMode) {
switch (mode) {
@ -119,7 +119,7 @@ function findKeyframe(keyframes: Keyframe[], time: number, mode: FindKeyframeMod
case 'after': {
return findNextKeyframe(keyframes, time);
}
case 'consistent': {
case 'keyframeCutFix': {
return findNextKeyframe(keyframes,time);
}
default: {

View File

@ -290,10 +290,10 @@ function useSegments({ filePath, workingRef, setWorking, setCutProgress, videoSt
async function align(key: string) {
const time = newSegment[key];
if (filePath == null) throw new Error();
if (filePath === null) throw new Error();
let keyframe = await findKeyframeNearTime({ filePath, streamIndex: videoStream.index, time, mode });
if (keyframe == null) {
if (mode != 'consistent') {
if (keyframe === null) {
if (mode !== 'keyframeCutFix') {
throw new Error(`Cannot find any keyframe within 60 seconds of frame ${time}`);
}
keyframe = duration;
@ -301,17 +301,17 @@ function useSegments({ filePath, workingRef, setWorking, setCutProgress, videoSt
newSegment[key] = keyframe;
}
if (startOrEnd.includes('start')) {
if (mode == 'consistent') {
if (mode === 'keyframeCutFix') {
newSegment.start += frameTime * 0.3;
}
await align('start');
if (mode == 'consistent') {
if (mode === 'keyframeCutFix') {
newSegment.start -= frameTime * 0.7;
}
}
if (startOrEnd.includes('end')) {
await align('end');
if (mode == 'consistent' && newSegment.end != duration) {
if (mode === 'keyframeCutFix' && newSegment.end !== duration) {
newSegment.end -= frameTime * 0.3;
}
}