1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00
This commit is contained in:
Mikael Finstad 2024-09-25 15:46:05 +08:00
parent 6c9b1ba708
commit fa7b36f69f
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
2 changed files with 30 additions and 4 deletions

View File

@ -53,7 +53,12 @@ export function abortFfmpegs() {
}); });
} }
function handleProgress(process: { stderr: Readable | null }, durationIn: number | undefined, onProgress: (a: number) => void, customMatcher: (a: string) => void = () => undefined) { function handleProgress(
process: { stderr: Readable | null },
durationIn: number | undefined,
onProgress: (a: number) => void,
customMatcher: (a: string) => void = () => undefined,
) {
if (!onProgress) return; if (!onProgress) return;
if (process.stderr == null) return; if (process.stderr == null) return;
onProgress(0); onProgress(0);
@ -425,7 +430,15 @@ function getCodecOpts(captureFormat: CaptureFormat) {
} }
export async function captureFrames({ from, to, videoPath, outPathTemplate, quality, filter, framePts, onProgress, captureFormat }: { export async function captureFrames({ from, to, videoPath, outPathTemplate, quality, filter, framePts, onProgress, captureFormat }: {
from: number, to: number, videoPath: string, outPathTemplate: string, quality: number, filter?: string | undefined, framePts?: boolean | undefined, onProgress: (p: number) => void, captureFormat: CaptureFormat, from: number,
to: number,
videoPath: string,
outPathTemplate: string,
quality: number,
filter?: string | undefined,
framePts?: boolean | undefined,
onProgress: (p: number) => void,
captureFormat: CaptureFormat,
}) { }) {
const args = [ const args = [
'-ss', String(from), '-ss', String(from),

View File

@ -25,9 +25,22 @@ function getFrameFromVideo(video: HTMLVideoElement, format: CaptureFormat, quali
return dataUriToBuffer(dataUri); return dataUriToBuffer(dataUri);
} }
export default ({ formatTimecode, treatOutputFileModifiedTimeAsStart }: { formatTimecode: FormatTimecode, treatOutputFileModifiedTimeAsStart?: boolean | undefined | null }) => { export default ({ formatTimecode, treatOutputFileModifiedTimeAsStart }: {
formatTimecode: FormatTimecode,
treatOutputFileModifiedTimeAsStart?: boolean | undefined | null,
}) => {
const captureFramesRange = useCallback(async ({ customOutDir, filePath, fps, fromTime, toTime, estimatedMaxNumFiles, captureFormat, quality, filter, onProgress, outputTimestamps }: { const captureFramesRange = useCallback(async ({ customOutDir, filePath, fps, fromTime, toTime, estimatedMaxNumFiles, captureFormat, quality, filter, onProgress, outputTimestamps }: {
customOutDir, filePath: string, fps: number, fromTime: number, toTime: number, estimatedMaxNumFiles: number, captureFormat: CaptureFormat, quality: number, filter?: string | undefined, onProgress: (a: number) => void, outputTimestamps: boolean customOutDir: string | undefined,
filePath: string,
fps: number,
fromTime: number,
toTime: number,
estimatedMaxNumFiles: number,
captureFormat: CaptureFormat,
quality: number,
filter?: string | undefined,
onProgress: (a: number) => void,
outputTimestamps: boolean,
}) => { }) => {
const getSuffix = (prefix: string) => `${prefix}.${captureFormat}`; const getSuffix = (prefix: string) => `${prefix}.${captureFormat}`;