Skip to content

The swiss army knife of lossless video/audio editing

Add option to include all streams (#76)

matdv0a3b716591f2
diff --git a/src/ffmpeg.js b/src/ffmpeg.js
index 025ae710..2aa0f1c6 100644
--- a/src/ffmpeg.js
+++ b/src/ffmpeg.js
@@ -56,7 +56,8 @@ function handleProgress(process, cutDuration, onProgress) {
}
async function cut({
- customOutDir, filePath, format, cutFrom, cutTo, videoDuration, rotation, onProgress,
+ customOutDir, filePath, format, cutFrom, cutTo, videoDuration, rotation, includeAllStreams,
+ onProgress,
}) {
const ext = path.extname(filePath) || `.${format}`;
const cutSpecification = `${util.formatDuration(cutFrom, true)}-${util.formatDuration(cutTo, true)}`;
@@ -73,6 +74,7 @@ async function cut({
const ffmpegArgs = [
'-i', filePath, '-y', '-vcodec', 'copy', '-acodec', 'copy', '-scodec', 'copy',
...cutFromArgs, ...cutToArgs,
+ ...(includeAllStreams ? ['-map', '0'] : []),
'-map_metadata', '0',
...rotationArgs,
'-f', format,
diff --git a/src/renderer.jsx b/src/renderer.jsx
index 33f8f708..00155739 100644
--- a/src/renderer.jsx
+++ b/src/renderer.jsx
@@ -97,6 +97,7 @@ class App extends React.Component {
captureFormat: 'jpeg',
rotation: 360,
cutProgress: undefined,
+ includeAllStreams: false,
};
this.state = _.cloneDeep(defaultState);
@@ -253,6 +254,10 @@ class App extends React.Component {
this.setState({ captureFormat: isPng ? 'jpeg' : 'png' });
}
+ toggleIncludeAllStreams() {
+ this.setState({ includeAllStreams: !this.state.includeAllStreams });
+ }
+
jumpCutStart() {
seekAbs(this.state.cutStartTime);
}
@@ -309,6 +314,7 @@ class App extends React.Component {
const fileFormat = this.state.fileFormat;
const videoDuration = this.state.duration;
const rotation = this.isRotationSet() ? this.getRotation() : undefined;
+ const includeAllStreams = this.state.includeAllStreams;
if (!this.areCutTimesSet()) {
return alert('Please select both start and end time');
@@ -327,6 +333,7 @@ class App extends React.Component {
cutTo: cutEndTime,
videoDuration,
rotation,
+ includeAllStreams,
onProgress: progress => this.onCutProgress(progress),
});
} catch (err) {
@@ -531,6 +538,13 @@ class App extends React.Component {
</div>
<div className="right-menu">
+ <button
+ title={`Set output streams. Current: ${this.state.includeAllStreams ? 'include (and cut) all streams' : 'include only primary streams'}`}
+ onClick={withBlur(() => this.toggleIncludeAllStreams())}
+ >
+ {this.state.includeAllStreams ? 'all' : 'ps'}
+ </button>
+
<button
title={`Set output rotation. Current: ${this.isRotationSet() ? this.getRotationStr() : 'Don\'t modify'}`}
onClick={withBlur(() => this.increaseRotation())}