The swiss army knife of lossless video/audio editing
add new "opposing" align mode
Mikael Finstad260301f94d42
diff --git a/locales/en/translation.json b/locales/en/translation.jsonindex e23dba8a..5e8b3ec1 100644--- a/locales/en/translation.json+++ b/locales/en/translation.json@@ -632,6 +632,7 @@"Segment mode: \"{{mode1}}\" will create segments bounding the black sections. \"{{mode2}}\" will create segments that start/stop at the center of each black section.": "Segment mode: \"{{mode1}}\" will create segments bounding the black sections. \"{{mode2}}\" will create segments that start/stop at the center of each black section.","Segment mode: \"{{mode1}}\" will create segments bounding the silent sections. \"{{mode2}}\" will create segments that start/stop at the center of each silent section.": "Segment mode: \"{{mode1}}\" will create segments bounding the silent sections. \"{{mode2}}\" will create segments that start/stop at the center of each silent section.","Segment start time must precede end time": "Segment start time must precede end time",+ "Segment start to previous keyframe and end to next keyframe": "Segment start to previous keyframe and end to next keyframe","Segment starts after 01:00": "Segment starts after 01:00","Segment tag value": "Segment tag value","Segment tags": "Segment tags",diff --git a/src/renderer/src/dialogs/index.tsx b/src/renderer/src/dialogs/index.tsxindex 895365f8..44c10cef 100644--- a/src/renderer/src/dialogs/index.tsx+++ b/src/renderer/src/dialogs/index.tsx@@ -334,14 +334,15 @@ export async function askForAlignSegments() {const startOrEnd = await askForSegmentsStartOrEnd(i18n.t('Do you want to align the segment start or end timestamps to keyframes?'));if (startOrEnd == null) return undefined;- const { value: mode } = await getSwal().Swal.fire<FindKeyframeMode>({+ const { value: mode } = await getSwal().Swal.fire<FindKeyframeMode | 'opposing'>({input: 'radio',showCancelButton: true,inputOptions: {nearest: i18n.t('Nearest keyframe'),before: i18n.t('Previous keyframe'),after: i18n.t('Next keyframe'),- } satisfies Record<FindKeyframeMode, unknown>,+ opposing: i18n.t('Segment start to previous keyframe and end to next keyframe'),+ } satisfies Record<FindKeyframeMode | 'opposing', unknown>,inputValue: 'before',text: i18n.t('Do you want to align segment times to the nearest, previous or next keyframe?'),});diff --git a/src/renderer/src/hooks/useSegments.tsx b/src/renderer/src/hooks/useSegments.tsxindex 74f0f647..43714737 100644--- a/src/renderer/src/hooks/useSegments.tsx+++ b/src/renderer/src/hooks/useSegments.tsx@@ -521,7 +521,12 @@ function useSegments({ filePath, workingRef, setWorking, setProgress, videoStreaconst time = newSegment[key];invariant(filePath != null);if (time != null) {- const keyframe = await findKeyframeNearTime({ filePath, streamIndex: videoStream.index, time, mode });+ const keyframe = await findKeyframeNearTime({+ filePath,+ streamIndex: videoStream.index,+ time,+ mode: mode === 'opposing' ? (key === 'start' ? 'before' : 'after') : mode,+ });if (keyframe == null) throw new UserFacingError(i18n.t('Cannot find any keyframe within 60 seconds of frame {{time}}', { time }));newSegment[key] = keyframe;}