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:
parent
027790c93e
commit
a75e47432f
@ -57,7 +57,7 @@ function handleProgress(process, cutDuration, onProgress) {
|
|||||||
|
|
||||||
async function cut({
|
async function cut({
|
||||||
customOutDir, filePath, format, cutFrom, cutTo, videoDuration, rotation, includeAllStreams,
|
customOutDir, filePath, format, cutFrom, cutTo, videoDuration, rotation, includeAllStreams,
|
||||||
onProgress,
|
onProgress, stripAudio,
|
||||||
}) {
|
}) {
|
||||||
const ext = path.extname(filePath) || `.${format}`;
|
const ext = path.extname(filePath) || `.${format}`;
|
||||||
const cutSpecification = `${util.formatDuration(cutFrom, true)}-${util.formatDuration(cutTo, true)}`;
|
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 rotationArgs = rotation !== undefined ? ['-metadata:s:v:0', `rotate=${rotation}`] : [];
|
||||||
const ffmpegArgs = [
|
const ffmpegArgs = [
|
||||||
'-i', filePath, '-y', '-vcodec', 'copy', '-acodec', 'copy', '-scodec', 'copy',
|
'-i', filePath, '-y',
|
||||||
|
...(stripAudio ? ['-an'] : ['-acodec', 'copy']),
|
||||||
|
'-vcodec', 'copy',
|
||||||
|
'-scodec', 'copy',
|
||||||
...cutFromArgs, ...cutToArgs,
|
...cutFromArgs, ...cutToArgs,
|
||||||
...(includeAllStreams ? ['-map', '0'] : []),
|
...(includeAllStreams ? ['-map', '0'] : []),
|
||||||
'-map_metadata', '0',
|
'-map_metadata', '0',
|
||||||
|
@ -98,6 +98,7 @@ class App extends React.Component {
|
|||||||
rotation: 360,
|
rotation: 360,
|
||||||
cutProgress: undefined,
|
cutProgress: undefined,
|
||||||
includeAllStreams: false,
|
includeAllStreams: false,
|
||||||
|
stripAudio: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
this.state = _.cloneDeep(defaultState);
|
this.state = _.cloneDeep(defaultState);
|
||||||
@ -315,6 +316,7 @@ class App extends React.Component {
|
|||||||
const videoDuration = this.state.duration;
|
const videoDuration = this.state.duration;
|
||||||
const rotation = this.isRotationSet() ? this.getRotation() : undefined;
|
const rotation = this.isRotationSet() ? this.getRotation() : undefined;
|
||||||
const includeAllStreams = this.state.includeAllStreams;
|
const includeAllStreams = this.state.includeAllStreams;
|
||||||
|
const stripAudio = this.state.stripAudio;
|
||||||
|
|
||||||
if (!this.areCutTimesSet()) {
|
if (!this.areCutTimesSet()) {
|
||||||
return alert('Please select both start and end time');
|
return alert('Please select both start and end time');
|
||||||
@ -334,6 +336,7 @@ class App extends React.Component {
|
|||||||
videoDuration,
|
videoDuration,
|
||||||
rotation,
|
rotation,
|
||||||
includeAllStreams,
|
includeAllStreams,
|
||||||
|
stripAudio,
|
||||||
onProgress: progress => this.onCutProgress(progress),
|
onProgress: progress => this.onCutProgress(progress),
|
||||||
});
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
@ -545,6 +548,13 @@ class App extends React.Component {
|
|||||||
{this.state.includeAllStreams ? 'all' : 'ps'}
|
{this.state.includeAllStreams ? 'all' : 'ps'}
|
||||||
</button>
|
</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
|
<button
|
||||||
title={`Set output rotation. Current: ${this.isRotationSet() ? this.getRotationStr() : 'Don\'t modify'}`}
|
title={`Set output rotation. Current: ${this.isRotationSet() ? this.getRotationStr() : 'Don\'t modify'}`}
|
||||||
onClick={withBlur(() => this.increaseRotation())}
|
onClick={withBlur(() => this.increaseRotation())}
|
||||||
|
Loading…
Reference in New Issue
Block a user