1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00

Add button to strip audio (#71)

This commit is contained in:
Mikael Finstad 2018-06-05 21:28:03 +02:00
parent 027790c93e
commit a75e47432f
2 changed files with 15 additions and 2 deletions

View File

@ -57,7 +57,7 @@ function handleProgress(process, cutDuration, onProgress) {
async function cut({
customOutDir, filePath, format, cutFrom, cutTo, videoDuration, rotation, includeAllStreams,
onProgress,
onProgress, stripAudio,
}) {
const ext = path.extname(filePath) || `.${format}`;
const cutSpecification = `${util.formatDuration(cutFrom, true)}-${util.formatDuration(cutTo, true)}`;
@ -72,7 +72,10 @@ async function cut({
const rotationArgs = rotation !== undefined ? ['-metadata:s:v:0', `rotate=${rotation}`] : [];
const ffmpegArgs = [
'-i', filePath, '-y', '-vcodec', 'copy', '-acodec', 'copy', '-scodec', 'copy',
'-i', filePath, '-y',
...(stripAudio ? ['-an'] : ['-acodec', 'copy']),
'-vcodec', 'copy',
'-scodec', 'copy',
...cutFromArgs, ...cutToArgs,
...(includeAllStreams ? ['-map', '0'] : []),
'-map_metadata', '0',

View File

@ -98,6 +98,7 @@ class App extends React.Component {
rotation: 360,
cutProgress: undefined,
includeAllStreams: false,
stripAudio: false,
};
this.state = _.cloneDeep(defaultState);
@ -315,6 +316,7 @@ class App extends React.Component {
const videoDuration = this.state.duration;
const rotation = this.isRotationSet() ? this.getRotation() : undefined;
const includeAllStreams = this.state.includeAllStreams;
const stripAudio = this.state.stripAudio;
if (!this.areCutTimesSet()) {
return alert('Please select both start and end time');
@ -334,6 +336,7 @@ class App extends React.Component {
videoDuration,
rotation,
includeAllStreams,
stripAudio,
onProgress: progress => this.onCutProgress(progress),
});
} catch (err) {
@ -545,6 +548,13 @@ class App extends React.Component {
{this.state.includeAllStreams ? 'all' : 'ps'}
</button>
<button
title={`Delete audio? Current: ${this.state.stripAudio ? 'delete audio tracks' : "don't delete audio tracks"}`}
onClick={withBlur(() => this.setState({ stripAudio: !this.state.stripAudio }))}
>
{this.state.stripAudio ? 'da' : 'ka'}
</button>
<button
title={`Set output rotation. Current: ${this.isRotationSet() ? this.getRotationStr() : 'Don\'t modify'}`}
onClick={withBlur(() => this.increaseRotation())}