1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-21 18:02:35 +01:00

Add option to include all streams (#76)

* Add option to include all streams
This commit is contained in:
matdv 2018-05-23 23:08:19 +02:00 committed by Mikael Finstad
parent 596a73d756
commit 0a3b716591
2 changed files with 17 additions and 1 deletions

View File

@ -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,

View File

@ -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())}