kopia lustrzana https://github.com/mifi/lossless-cut
Implement custom output dir button
rodzic
3d47759b0f
commit
08d9976482
|
@ -28,18 +28,21 @@ function canExecuteFfmpeg(ffmpegPath) {
|
|||
function getFfmpegPath() {
|
||||
const internalFfmpeg = path.join(__dirname, '..', 'app.asar.unpacked', 'ffmpeg', getWithExt('ffmpeg'));
|
||||
return canExecuteFfmpeg(internalFfmpeg)
|
||||
.then(() => internalFfmpeg)
|
||||
.catch(() => {
|
||||
console.log('Internal ffmpeg unavail');
|
||||
return which('ffmpeg');
|
||||
});
|
||||
.then(() => internalFfmpeg)
|
||||
.catch(() => {
|
||||
console.log('Internal ffmpeg unavail');
|
||||
return which('ffmpeg');
|
||||
});
|
||||
}
|
||||
|
||||
function cut(filePath, format, cutFrom, cutTo) {
|
||||
function cut(outputDir, filePath, format, cutFrom, cutTo) {
|
||||
return bluebird.try(() => {
|
||||
const ext = path.extname(filePath) || `.${format}`;
|
||||
const outFileAppend = `${util.formatDuration(cutFrom)}-${util.formatDuration(cutTo)}`;
|
||||
const outFile = `${filePath}-${outFileAppend}${ext}`;
|
||||
const duration = `${util.formatDuration(cutFrom)}-${util.formatDuration(cutTo)}`;
|
||||
const basename = path.basename(filePath);
|
||||
const outFile = outputDir ?
|
||||
path.join(outputDir, `${basename}-${duration}${ext}`) :
|
||||
`${filePath}-${duration}${ext}`;
|
||||
|
||||
console.log('Cutting from', cutFrom, 'to', cutTo);
|
||||
|
||||
|
|
|
@ -4,6 +4,7 @@ const keyboardJs = require('keyboardjs');
|
|||
const _ = require('lodash');
|
||||
const captureFrame = require('capture-frame');
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const Hammer = require('react-hammerjs');
|
||||
|
||||
const React = require('react');
|
||||
|
@ -13,6 +14,8 @@ const classnames = require('classnames');
|
|||
const ffmpeg = require('./ffmpeg');
|
||||
const util = require('./util');
|
||||
|
||||
const dialog = electron.remote.dialog;
|
||||
|
||||
function getVideo() {
|
||||
return $('#player video')[0];
|
||||
}
|
||||
|
@ -131,6 +134,12 @@ class App extends React.Component {
|
|||
this.setState({ cutEndTime: this.state.currentTime });
|
||||
}
|
||||
|
||||
setOutputDir() {
|
||||
dialog.showOpenDialog({ properties: ['openDirectory'] }, (paths) => {
|
||||
this.setState({ outputDir: (paths && paths.length === 1) ? paths[0] : undefined });
|
||||
});
|
||||
}
|
||||
|
||||
jumpCutStart() {
|
||||
seekAbs(this.state.cutStartTime);
|
||||
}
|
||||
|
@ -191,7 +200,9 @@ class App extends React.Component {
|
|||
}
|
||||
|
||||
this.setState({ working: true });
|
||||
return ffmpeg.cut(filePath, this.state.fileFormat, cutStartTime, cutEndTime)
|
||||
const outputDir = this.state.outputDir;
|
||||
const fileFormat = this.state.fileFormat;
|
||||
return ffmpeg.cut(outputDir, filePath, fileFormat, cutStartTime, cutEndTime)
|
||||
.catch((err) => {
|
||||
console.error('stdout:', err.stdout);
|
||||
console.error('stderr:', err.stderr);
|
||||
|
@ -283,7 +294,7 @@ class App extends React.Component {
|
|||
</div>
|
||||
<div>
|
||||
<button
|
||||
className="jump-cut-start" title="Cut start time"
|
||||
className="jump-cut-start" title="Cut start time (jump)"
|
||||
onClick={() => this.jumpCutStart()}
|
||||
>{util.formatDuration(this.state.cutStartTime || 0)}</button>
|
||||
<i
|
||||
|
@ -305,15 +316,21 @@ class App extends React.Component {
|
|||
onClick={() => this.setCutEnd()}
|
||||
/>
|
||||
<button
|
||||
className="jump-cut-end" title="Cut end time"
|
||||
className="jump-cut-end" title="Cut end time (jump)"
|
||||
onClick={() => this.jumpCutEnd()}
|
||||
>{util.formatDuration(this.state.cutEndTime || 0)}</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="right-menu">
|
||||
<button
|
||||
title={`Custom output dir (cancel to restore default). Current: ${this.state.outputDir || 'Not set'}`}
|
||||
onClick={() => this.setOutputDir()}
|
||||
>
|
||||
{this.state.outputDir ? `...${this.state.outputDir.substr(-10)}` : 'OUT PATH'}
|
||||
</button>
|
||||
<button title="Format">
|
||||
{this.state.fileFormat || '-'}
|
||||
{this.state.fileFormat || 'FMT'}
|
||||
</button>
|
||||
<button className="playback-rate" title="Playback rate">
|
||||
{_.round(this.state.playbackRate, 1) || 1}x
|
||||
|
|
Ładowanie…
Reference in New Issue