Skip to content

The swiss army knife of lossless video/audio editing

cut also externally added tracks

Mikael Finstad32a5b2380f48
diff --git a/src/renderer/src/StreamsSelector.tsx b/src/renderer/src/StreamsSelector.tsx
index afb9f758..eac4e417 100644
--- a/src/renderer/src/StreamsSelector.tsx
+++ b/src/renderer/src/StreamsSelector.tsx
@@ -3,7 +3,7 @@ import { memo, useState, useMemo, useCallback, Dispatch, SetStateAction, CSSProp
import { FaImage, FaPaperclip, FaVideo, FaVideoSlash, FaFileImport, FaVolumeUp, FaVolumeMute, FaBan, FaFileExport } from 'react-icons/fa';
import { GoFileBinary } from 'react-icons/go';
import { MdSubtitles } from 'react-icons/md';
-import { BookIcon, MoreIcon, Position, Popover, Menu, TrashIcon, EditIcon, InfoSignIcon, IconButton, SortAscIcon, SortDescIcon, ForkIcon, WarningSignIcon, EyeOpenIcon, FilterIcon } from 'evergreen-ui';
+import { BookIcon, MoreIcon, Position, Popover, Menu, TrashIcon, EditIcon, InfoSignIcon, IconButton, SortAscIcon, SortDescIcon, ForkIcon, EyeOpenIcon, FilterIcon } from 'evergreen-ui';
import { useTranslation } from 'react-i18next';
import prettyBytes from 'pretty-bytes';
@@ -480,10 +480,6 @@ function StreamsSelector({
))}
<div style={{ margin: '1em 1em' }}>
- {externalFilesEntries.length > 0 && (
- <div style={{ marginBottom: '1em' }}><WarningSignIcon color="warning" /> {t('Note: Cutting and including external tracks at the same time does not yet work. If you want to do both, it must be done as separate operations. See github issue #896.')}</div>
- )}
-
<Button style={{ marginBottom: '1em', padding: '0.3em 1em' }} onClick={showAddStreamSourceDialog}>
<FaFileImport style={{ verticalAlign: 'middle', marginRight: '.5em' }} /> {t('Include more tracks from other file')}
</Button>
diff --git a/src/renderer/src/hooks/useFfmpegOperations.ts b/src/renderer/src/hooks/useFfmpegOperations.ts
index 69bbce4f..78d14785 100644
--- a/src/renderer/src/hooks/useFfmpegOperations.ts
+++ b/src/renderer/src/hooks/useFfmpegOperations.ts
@@ -277,24 +277,18 @@ function useFfmpegOperations({ filePath, treatInputFileModifiedTimeAsStart, trea
const copyFileStreamsFiltered = copyFileStreams.filter(({ streamIds }) => streamIds.length > 0);
// remove -avoid_negative_ts make_zero when not cutting start (no -ss), or else some videos get blank first frame in QuickLook
- const avoidNegativeTsArgs = cuttingStart && avoidNegativeTs ? ['-avoid_negative_ts', String(avoidNegativeTs)] : [];
-
- const inputFilesArgs = flatMap(copyFileStreamsFiltered, ({ path }) => ['-i', path]);
- const inputFilesArgsWithCuts = ssBeforeInput ? [
- ...cutFromArgs,
- ...inputFilesArgs,
- ...cutToArgs,
- ...avoidNegativeTsArgs,
- ] : [
- ...inputFilesArgs,
- ...cutFromArgs,
- ...cutToArgs,
- ];
-
- const inputArgs = [
- ...inputFilesArgsWithCuts,
- ...getChaptersInputArgs(chaptersPath),
- ];
+ const avoidNegativeTsArgs = cuttingStart && avoidNegativeTs && ssBeforeInput ? ['-avoid_negative_ts', String(avoidNegativeTs)] : [];
+
+ // If cutting multiple files, `-ss` must be before `-i`, regardless of `ssBeforeInput` choice
+ // and it seems that `-t` must be after `-i` #896
+ const inputFilesArgs = copyFileStreamsFiltered.length > 1
+ ? flatMap(copyFileStreamsFiltered, ({ path }) => [...cutFromArgs, '-i', path, ...cutToArgs])
+ : [
+ ...(ssBeforeInput ? cutFromArgs : []),
+ '-i', copyFileStreamsFiltered[0]!.path,
+ ...(!ssBeforeInput ? cutFromArgs : []),
+ ...cutToArgs,
+ ];
const chaptersInputIndex = copyFileStreamsFiltered.length;
@@ -383,7 +377,10 @@ function useFfmpegOperations({ filePath, treatInputFileModifiedTimeAsStart, trea
...rotationArgs,
- ...inputArgs,
+ ...inputFilesArgs,
+ ...getChaptersInputArgs(chaptersPath),
+
+ ...avoidNegativeTsArgs,
...mapStreamsArgs,