mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-23 02:42:37 +01:00
refactor
This commit is contained in:
parent
684a45b694
commit
12960ffb57
@ -199,7 +199,7 @@ const App = memo(() => {
|
||||
} = useUserPreferences();
|
||||
|
||||
const {
|
||||
mergeFiles: ffmpegMergeFiles, html5ifyDummy, cutMultiple, autoMergeSegments, html5ify, fixInvalidDuration,
|
||||
concatFiles, html5ifyDummy, cutMultiple, autoMergeSegments, html5ify, fixInvalidDuration,
|
||||
} = useFfmpegOperations({ filePath, enableTransferTimestamps });
|
||||
|
||||
const outSegTemplateOrDefault = outSegTemplate || defaultOutSegTemplate;
|
||||
@ -695,7 +695,7 @@ const App = memo(() => {
|
||||
}
|
||||
|
||||
// console.log('merge', paths);
|
||||
await ffmpegMergeFiles({ paths, outPath, outDir, fileFormat: fileFormat2, includeAllStreams, ffmpegExperimental, onProgress: setCutProgress, preserveMovData, movFastStart, preserveMetadataOnMerge, chapters: chaptersFromSegments });
|
||||
await concatFiles({ paths, outPath, outDir, fileFormat: fileFormat2, includeAllStreams, ffmpegExperimental, onProgress: setCutProgress, preserveMovData, movFastStart, preserveMetadataOnMerge, chapters: chaptersFromSegments });
|
||||
openDirToast({ icon: 'success', dirPath: outDir, text: i18n.t('Files merged!') });
|
||||
} catch (err) {
|
||||
if (isOutOfSpaceError(err)) {
|
||||
@ -708,7 +708,7 @@ const App = memo(() => {
|
||||
setWorking();
|
||||
setCutProgress();
|
||||
}
|
||||
}, [setWorking, ensureAccessibleDirectories, customOutDir, segmentsToChapters, ffmpegMergeFiles, ffmpegExperimental, preserveMovData, movFastStart, preserveMetadataOnMerge]);
|
||||
}, [setWorking, ensureAccessibleDirectories, customOutDir, segmentsToChapters, concatFiles, ffmpegExperimental, preserveMovData, movFastStart, preserveMetadataOnMerge]);
|
||||
|
||||
const concatCurrentBatch = useCallback(() => {
|
||||
if (batchFiles.length < 2) {
|
||||
|
@ -236,7 +236,7 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
|
||||
}
|
||||
}, [filePath, optionalTransferTimestamps]);
|
||||
|
||||
const mergeFiles = useCallback(async ({ paths, outDir, outPath, allStreams, outFormat, ffmpegExperimental, onProgress = () => {}, preserveMovData, movFastStart, chapters, preserveMetadataOnMerge }) => {
|
||||
const concatFiles = useCallback(async ({ paths, outDir, outPath, includeAllStreams, outFormat, ffmpegExperimental, onProgress = () => {}, preserveMovData, movFastStart, chapters, preserveMetadataOnMerge }) => {
|
||||
console.log('Merging files', { paths }, 'to', outPath);
|
||||
|
||||
const durations = await pMap(paths, getDuration, { concurrency: 1 });
|
||||
@ -277,7 +277,7 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
|
||||
}
|
||||
|
||||
let map;
|
||||
if (allStreams) map = ['-map', '0'];
|
||||
if (includeAllStreams) map = ['-map', '0'];
|
||||
// If preserveMetadataOnMerge option is enabled, we need to explicitly map even if allStreams=false.
|
||||
// We cannot use the ffmpeg's automatic stream selection or else ffmpeg might use the metadata source input (index 1)
|
||||
// instead of the concat input (index 0)
|
||||
@ -349,9 +349,9 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
|
||||
|
||||
const chapters = await createChaptersFromSegments({ segmentPaths, chapterNames });
|
||||
|
||||
await mergeFiles({ paths: segmentPaths, outDir, outPath, outFormat, allStreams: true, ffmpegExperimental, onProgress, preserveMovData, movFastStart, chapters, preserveMetadataOnMerge });
|
||||
await concatFiles({ paths: segmentPaths, outDir, outPath, outFormat, includeAllStreams: true, ffmpegExperimental, onProgress, preserveMovData, movFastStart, chapters, preserveMetadataOnMerge });
|
||||
if (autoDeleteMergedSegments) await pMap(segmentPaths, path => fs.unlink(path), { concurrency: 5 });
|
||||
}, [filePath, mergeFiles]);
|
||||
}, [concatFiles, filePath]);
|
||||
|
||||
const html5ify = useCallback(async ({ customOutDir, filePath: filePathArg, speed, hasAudio, hasVideo, onProgress }) => {
|
||||
const outPath = getHtml5ifiedPath(customOutDir, filePathArg, speed);
|
||||
@ -512,7 +512,7 @@ function useFfmpegOperations({ filePath, enableTransferTimestamps }) {
|
||||
}, [filePath, optionalTransferTimestamps]);
|
||||
|
||||
return {
|
||||
cutMultiple, mergeFiles, html5ify, html5ifyDummy, fixInvalidDuration, autoMergeSegments,
|
||||
cutMultiple, concatFiles, html5ify, html5ifyDummy, fixInvalidDuration, autoMergeSegments,
|
||||
};
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user