Skip to content

The swiss army knife of lossless video/audio editing

refactor

Mikael Finstad34b5a47cfa39
diff --git a/src/App.jsx b/src/App.jsx
index 97b584e4..fec8007f 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -684,12 +684,12 @@ const App = memo(() => {
const exportExtraStreams = autoExportExtraStreams && nonCopiedExtraStreams.length > 0;
- const copyStreamIds = useMemo(() => Object.entries(copyStreamIdsByFile).map(([path, streamIdsMap]) => ({
+ const copyFileStreams = useMemo(() => Object.entries(copyStreamIdsByFile).map(([path, streamIdsMap]) => ({
path,
streamIds: Object.keys(streamIdsMap).filter(index => streamIdsMap[index]),
})), [copyStreamIdsByFile]);
- const numStreamsToCopy = copyStreamIds
+ const numStreamsToCopy = copyFileStreams
.reduce((acc, { streamIds }) => acc + streamIds.length, 0);
const numStreamsTotal = [
@@ -1006,7 +1006,7 @@ const App = memo(() => {
isCustomFormatSelected,
videoDuration: duration,
rotation: effectiveRotation,
- copyStreamIds,
+ copyFileStreams,
keyframeCut,
segments: outSegments,
onProgress: setCutProgress,
@@ -1054,7 +1054,7 @@ const App = memo(() => {
}, [
effectiveRotation, outSegments, handleCutFailed,
working, duration, filePath, keyframeCut,
- autoMerge, customOutDir, fileFormat, haveInvalidSegs, copyStreamIds, numStreamsToCopy,
+ autoMerge, customOutDir, fileFormat, haveInvalidSegs, copyFileStreams, numStreamsToCopy,
exportExtraStreams, nonCopiedExtraStreams, outputDir, shortestFlag, isCustomFormatSelected,
]);
diff --git a/src/ffmpeg.js b/src/ffmpeg.js
index 826c1bc5..a1f886d5 100644
--- a/src/ffmpeg.js
+++ b/src/ffmpeg.js
@@ -189,7 +189,7 @@ export function findNearestKeyFrameTime({ frames, time, direction, fps }) {
async function cut({
filePath, outFormat, cutFrom, cutTo, videoDuration, rotation,
- onProgress, copyStreamIds, keyframeCut, outPath, appendFfmpegCommandLog, shortestFlag,
+ onProgress, copyFileStreams, keyframeCut, outPath, appendFfmpegCommandLog, shortestFlag,
}) {
const cuttingStart = isCuttingStart(cutFrom);
const cuttingEnd = isCuttingEnd(cutTo, videoDuration);
@@ -203,9 +203,9 @@ async function cut({
const cutFromArgs = cuttingStart ? ['-ss', cutFrom.toFixed(5)] : [];
const cutToArgs = cuttingEnd ? ['-t', cutDuration.toFixed(5)] : [];
- const copyStreamIdsFiltered = copyStreamIds.filter(({ streamIds }) => streamIds.length > 0);
+ const copyFileStreamsFiltered = copyFileStreams.filter(({ streamIds }) => streamIds.length > 0);
- const inputArgs = flatMap(copyStreamIdsFiltered, ({ path }) => ['-i', path]);
+ const inputArgs = flatMap(copyFileStreamsFiltered, ({ path }) => ['-i', path]);
const inputCutArgs = ssBeforeInput ? [
...cutFromArgs,
...inputArgs,
@@ -228,7 +228,7 @@ async function cut({
...(shortestFlag ? ['-shortest'] : []),
- ...flatMapDeep(copyStreamIdsFiltered, ({ streamIds }, fileIndex) => streamIds.map(streamId => ['-map', `${fileIndex}:${streamId}`])),
+ ...flatMapDeep(copyFileStreamsFiltered, ({ streamIds }, fileIndex) => streamIds.map(streamId => ['-map', `${fileIndex}:${streamId}`])),
'-map_metadata', '0',
// https://video.stackexchange.com/questions/23741/how-to-prevent-ffmpeg-from-dropping-metadata
'-movflags', 'use_metadata_tags',
@@ -261,7 +261,7 @@ function getOutFileExtension({ isCustomFormatSelected, outFormat, filePath }) {
export async function cutMultiple({
customOutDir, filePath, segments: segmentsUnsorted, videoDuration, rotation,
- onProgress, keyframeCut, copyStreamIds, outFormat, isCustomFormatSelected,
+ onProgress, keyframeCut, copyFileStreams, outFormat, isCustomFormatSelected,
appendFfmpegCommandLog, shortestFlag,
}) {
const segments = sortBy(segmentsUnsorted, 'cutFrom');
@@ -292,7 +292,7 @@ export async function cutMultiple({
outFormat,
videoDuration,
rotation,
- copyStreamIds,
+ copyFileStreams,
keyframeCut,
cutFrom: start,
cutTo: end,
@@ -704,7 +704,7 @@ export async function extractWaveform({ filePath, outPath }) {
console.timeEnd('ffmpeg');
}
-// see capture-frame.js
+// See also capture-frame.js
export async function captureFrame({ timestamp, videoPath, outPath }) {
const args = [
'-ss', timestamp,