mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 11:43:17 +01:00
fix lint
This commit is contained in:
parent
fafbe91e3f
commit
82db08d4cd
@ -5,7 +5,7 @@ import pMap from 'p-map';
|
|||||||
import invariant from 'tiny-invariant';
|
import invariant from 'tiny-invariant';
|
||||||
import sortBy from 'lodash/sortBy';
|
import sortBy from 'lodash/sortBy';
|
||||||
|
|
||||||
import { detectSceneChanges as ffmpegDetectSceneChanges, readFrames, mapTimesToSegments, findKeyframeNearTime, getStreamFps, getDuration } from '../ffmpeg';
|
import { detectSceneChanges as ffmpegDetectSceneChanges, readFrames, mapTimesToSegments, findKeyframeNearTime, getStreamFps } from '../ffmpeg';
|
||||||
import { handleError, shuffleArray } from '../util';
|
import { handleError, shuffleArray } from '../util';
|
||||||
import { errorToast } from '../swal';
|
import { errorToast } from '../swal';
|
||||||
import { showParametersDialog } from '../dialogs/parameters';
|
import { showParametersDialog } from '../dialogs/parameters';
|
||||||
@ -283,14 +283,13 @@ function useSegments({ filePath, workingRef, setWorking, setCutProgress, videoSt
|
|||||||
|
|
||||||
if (filePath == null) throw new Error();
|
if (filePath == null) throw new Error();
|
||||||
const frameTime = 1 / (getStreamFps(videoStream) || 1000);
|
const frameTime = 1 / (getStreamFps(videoStream) || 1000);
|
||||||
const duration = await getDuration(filePath);
|
|
||||||
|
|
||||||
await modifySelectedSegmentTimes(async (segment) => {
|
await modifySelectedSegmentTimes(async (segment) => {
|
||||||
const newSegment = { ...segment };
|
const newSegment = { ...segment };
|
||||||
|
|
||||||
async function align(key: string) {
|
async function align(key: string) {
|
||||||
const time = newSegment[key];
|
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 });
|
let keyframe = await findKeyframeNearTime({ filePath, streamIndex: videoStream.index, time, mode });
|
||||||
if (keyframe === null) {
|
if (keyframe === null) {
|
||||||
if (mode !== 'keyframeCutFix') {
|
if (mode !== 'keyframeCutFix') {
|
||||||
@ -317,8 +316,7 @@ function useSegments({ filePath, workingRef, setWorking, setCutProgress, videoSt
|
|||||||
}
|
}
|
||||||
if (startOrEnd.includes('start')) {
|
if (startOrEnd.includes('start')) {
|
||||||
newSegment.start = Math.min(newSegment.start, newSegment.end - frameTime * 0.99); // don't know how ffmpeg interprets cuts between frames
|
newSegment.start = Math.min(newSegment.start, newSegment.end - frameTime * 0.99); // don't know how ffmpeg interprets cuts between frames
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
newSegment.end = Math.max(newSegment.start + frameTime * 0.99, newSegment.end);
|
newSegment.end = Math.max(newSegment.start + frameTime * 0.99, newSegment.end);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -330,7 +328,7 @@ function useSegments({ filePath, workingRef, setWorking, setCutProgress, videoSt
|
|||||||
} finally {
|
} finally {
|
||||||
setWorking(undefined);
|
setWorking(undefined);
|
||||||
}
|
}
|
||||||
}, [filePath, videoStream, modifySelectedSegmentTimes, setWorking, workingRef]);
|
}, [filePath, videoStream, modifySelectedSegmentTimes, setWorking, workingRef, duration]);
|
||||||
|
|
||||||
const updateSegOrder = useCallback((index, newOrder) => {
|
const updateSegOrder = useCallback((index, newOrder) => {
|
||||||
if (newOrder > cutSegments.length - 1 || newOrder < 0) return;
|
if (newOrder > cutSegments.length - 1 || newOrder < 0) return;
|
||||||
|
Loading…
Reference in New Issue
Block a user