mifi/lossless-cut · error · UserFacingError
Cannot find any keyframe within 60 seconds of frame {{time}}
Error message
Cannot find any keyframe within 60 seconds of frame {{time}} What it means
Thrown during keyframe alignment of segments when findKeyframeNearTime() returns null for a start or end boundary. The function probes keyframes near the given time within a bounded window (the 60s referenced in the message), and null means no keyframe was found on the requested side (before/after) of that time. It surfaces from a try/catch that routes the error through handleError.
Source
Thrown at src/renderer/src/hooks/useSegments.tsx:518
try {
const response = await askForAlignSegments();
if (response == null) return;
setWorking({ text: i18n.t('Aligning segments to keyframes') });
const { mode, startOrEnd } = response;
await modifySelectedSegmentTimes(async (segment) => {
const newSegment = { ...segment };
const align = async (key: 'start' | 'end') => {
const time = newSegment[key];
invariant(filePath != null);
if (time != null) {
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;
}
};
if (startOrEnd.includes('start')) await align('start');
if (startOrEnd.includes('end')) await align('end');
return newSegment;
});
} catch (err) {
handleError({ err });
} finally {
setWorking(undefined);
}
}, [videoStream, workingRef, setWorking, modifySelectedSegmentTimes, filePath, handleError]);
const updateSegOrder = useCallback((index: number, newOrder: number) => {
if (newOrder > cutSegments.length - 1 || newOrder < 0) return;
const newSegments = [...cutSegments];
const removedSeg = newSegments.splice(index, 1)[0];View on GitHub (pinned to 3b9a59c288)
Solutions
- Move the segment edge inward so a keyframe exists within 60s on the requested side before aligning.
- Re-encode the source with denser keyframes (-g / -force_key_frames) so alignment can succeed.
- If aligning at file boundaries is common, skip alignment for edges that are already at the first/last keyframe.
- Verify keyframe positions with `ffprobe -select_streams v -show_frames -skip_frame nokey`.
Example fix
// before
const keyframe = await findKeyframeNearTime({ filePath, streamIndex, time, mode });
if (keyframe == null) throw new UserFacingError(...);
// after
const keyframe = await findKeyframeNearTime({ filePath, streamIndex, time, mode });
if (keyframe == null) {
// leave the edge unaligned rather than throwing
return newSegment;
} Defensive patterns
Strategy: fallback
Validate before calling
const keyframe = await findKeyframeNearTime({ filePath, streamIndex, time, mode });
if (keyframe == null) {
// leave edge unaligned rather than throwing
return newSegment;
} Try / catch
try {
await alignSegmentsToKeyframes(segments);
} catch (err) {
if (err instanceof UserFacingError && /Cannot find any keyframe within 60 seconds/.test(err.message)) {
showError('Could not align one or more edges: no keyframe within 60s.');
return segments; // keep unaligned
}
throw err;
} Prevention
- Move segment edges inward so a keyframe exists within 60s on the requested side before aligning.
- Re-encode sources with denser keyframes (-g / -force_key_frames) for reliable alignment.
- Skip alignment for edges already at the first/last keyframe (file boundaries).
- Verify keyframe spacing with ffprobe before relying on alignment.
When it happens
Trigger: Invoking the align-segments-to-keyframes action on a segment whose start or end has no keyframe within the probe window on the requested side; aligning 'before' at the file start (no earlier keyframe) or 'after' near the file end (no later keyframe); a keyframe probe that returned empty due to a read error.
Common situations: Aligning a segment edge that sits at the extreme start or end of the file; very sparse keyframes (>60s apart) in long-GOP surveillance/HEVC footage; a damaged keyframe index; aligning on a stream type that has no keyframes.
Related errors
- Less than 2 frames found
- Failed to find next keyframe
- Failed to find any prev frame
- Failed to find any prev keyframe
- Cannot find any keyframe after the desired start cut point
AI-assisted analysis of mifi/lossless-cut@3b9a59c288 (2026-08-12).
Data as JSON: /api/errors/8d7ab98b943ad038.
Report an issue: GitHub.