From c9175d4270ce5a24d10007f756a2e1daab0e0b38 Mon Sep 17 00:00:00 2001 From: firstzerg Date: Sun, 14 Aug 2022 09:01:37 +0300 Subject: [PATCH] fix smartcut with segment between keyframes due https://github.com/mifi/lossless-cut/issues/126 --- src/hooks/useFfmpegOperations.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/hooks/useFfmpegOperations.js b/src/hooks/useFfmpegOperations.js index f05feebe..844d60fe 100644 --- a/src/hooks/useFfmpegOperations.js +++ b/src/hooks/useFfmpegOperations.js @@ -390,6 +390,13 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) { const smartCutSegmentsToConcat = [smartCutEncodedPartOutPath, smartCutMainPartOutPath]; + if (smartCutFrom > cutTo) { + if (!detectedFps) throw new Error('Smart cut is not possible when FPS is unknown'); + const file = getSegmentOutPath(); + await cutEncodeSmartPart({ filePath, cutFrom: desiredCutFrom, cutTo, outPath: file, outFormat, videoCodec, videoBitrate, videoStreamIndex, videoTimebase, allFilesMeta, copyFileStreams: copyFileStreamsFiltered, ffmpegExperimental }); + return file; + } + // for smart cut we need to use keyframe cut here await cutSingle({ cutFrom: smartCutFrom, cutTo, chaptersPath, outPath: smartCutMainPartOutPath, copyFileStreams: copyFileStreamsFiltered, keyframeCut: true, avoidNegativeTs: false, videoDuration, rotation, allFilesMeta, outFormat, appendFfmpegCommandLog, shortestFlag, ffmpegExperimental, preserveMovData, movFastStart, customTagsByFile, customTagsByStreamId, dispositionByStreamId, videoTimebase, onProgress: onCutProgress,