mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 11:43:17 +01:00
Bugfixes
Fix issue with two dots in extension Also don't cut end if endpoint is the end of the video
This commit is contained in:
parent
305fae7a94
commit
4493aa5572
@ -55,21 +55,24 @@ function handleProgress(process, cutDuration, onProgress) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function cut(customOutDir, filePath, format, cutFrom, cutTo, rotation, onProgress) {
|
async function cut({
|
||||||
const extWithoutDot = path.extname(filePath) || `.${format}`;
|
customOutDir, filePath, format, cutFrom, cutTo, videoDuration, rotation, onProgress,
|
||||||
const ext = `.${extWithoutDot}`;
|
}) {
|
||||||
const duration = `${util.formatDuration(cutFrom)}-${util.formatDuration(cutTo)}`;
|
const ext = path.extname(filePath) || `.${format}`;
|
||||||
|
const cutSpecification = `${util.formatDuration(cutFrom)}-${util.formatDuration(cutTo)}`;
|
||||||
|
|
||||||
const outPath = util.getOutPath(customOutDir, filePath, `${duration}${ext}`);
|
const outPath = util.getOutPath(customOutDir, filePath, `${cutSpecification}${ext}`);
|
||||||
|
|
||||||
console.log('Cutting from', cutFrom, 'to', cutTo);
|
console.log('Cutting from', cutFrom, 'to', cutTo);
|
||||||
|
|
||||||
// https://github.com/mifi/lossless-cut/issues/50
|
// https://github.com/mifi/lossless-cut/issues/50
|
||||||
const cutFromArgs = cutFrom === 0 ? [] : ['-ss', cutFrom];
|
const cutFromArgs = cutFrom === 0 ? [] : ['-ss', cutFrom];
|
||||||
|
const cutToArgs = cutTo === videoDuration ? [] : ['-t', cutTo - cutFrom];
|
||||||
|
|
||||||
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', '-vcodec', 'copy', '-acodec', 'copy', '-scodec', 'copy',
|
||||||
...cutFromArgs, '-t', cutTo - cutFrom,
|
...cutFromArgs, ...cutToArgs,
|
||||||
'-map_metadata', '0',
|
'-map_metadata', '0',
|
||||||
...rotationArgs,
|
...rotationArgs,
|
||||||
'-f', format,
|
'-f', format,
|
||||||
|
@ -285,19 +285,22 @@ class App extends React.Component {
|
|||||||
return alert('Start time must be before end time');
|
return alert('Start time must be before end time');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const videoDuration = this.state.duration;
|
||||||
|
|
||||||
this.setState({ working: true });
|
this.setState({ working: true });
|
||||||
const outputDir = this.state.customOutDir;
|
const outputDir = this.state.customOutDir;
|
||||||
const fileFormat = this.state.fileFormat;
|
const fileFormat = this.state.fileFormat;
|
||||||
try {
|
try {
|
||||||
return await ffmpeg.cut(
|
return await ffmpeg.cut({
|
||||||
outputDir,
|
customOutDir: outputDir,
|
||||||
filePath,
|
filePath,
|
||||||
fileFormat,
|
format: fileFormat,
|
||||||
cutStartTime,
|
cutFrom: cutStartTime,
|
||||||
cutEndTime,
|
cutTo: cutEndTime,
|
||||||
rotation,
|
videoDuration,
|
||||||
progress => this.onCutProgress(progress),
|
rotation,
|
||||||
);
|
onProgress: progress => this.onCutProgress(progress),
|
||||||
|
});
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
console.error('stdout:', err.stdout);
|
console.error('stdout:', err.stdout);
|
||||||
console.error('stderr:', err.stderr);
|
console.error('stderr:', err.stderr);
|
||||||
|
Loading…
Reference in New Issue
Block a user