mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-24 19:32:29 +01:00
allow custom output dir for merge and extract also
This commit is contained in:
parent
397b8b6bf8
commit
7c34b50f7f
@ -202,10 +202,10 @@ async function mergeFiles(paths, outPath) {
|
||||
console.log(result.stdout);
|
||||
}
|
||||
|
||||
async function mergeAnyFiles(paths) {
|
||||
async function mergeAnyFiles({ customOutDir, paths }) {
|
||||
const firstPath = paths[0];
|
||||
const ext = path.extname(firstPath);
|
||||
const outPath = `${firstPath}-merged${ext}`;
|
||||
const outPath = getOutPath(customOutDir, firstPath, `merged${ext}`);
|
||||
return mergeFiles(paths, outPath);
|
||||
}
|
||||
|
||||
@ -293,7 +293,7 @@ function mapCodecToOutputFormat(codec, type) {
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/32922226/extract-every-audio-and-subtitles-from-a-video-with-ffmpeg
|
||||
async function extractAllStreams(filePath) {
|
||||
async function extractAllStreams({ customOutDir, filePath }) {
|
||||
const { streams } = await getAllStreams(filePath);
|
||||
console.log('streams', streams);
|
||||
|
||||
@ -310,7 +310,7 @@ async function extractAllStreams(filePath) {
|
||||
const streamArgs = flatMap(outStreams, ({
|
||||
i, codec, type, format: { format, ext },
|
||||
}) => [
|
||||
'-map', `0:${i}`, '-c', 'copy', '-f', format, '-y', `${filePath}-${i}-${type}-${codec}.${ext}`,
|
||||
'-map', `0:${i}`, '-c', 'copy', '-f', format, '-y', getOutPath(customOutDir, filePath, `${i}-${type}-${codec}.${ext}`),
|
||||
]);
|
||||
|
||||
const ffmpegArgs = [
|
||||
|
@ -168,9 +168,10 @@ class App extends React.Component {
|
||||
try {
|
||||
this.setState({ working: true });
|
||||
|
||||
// TODO customOutDir ?
|
||||
const { customOutDir } = this.state;
|
||||
|
||||
// console.log('merge', paths);
|
||||
await ffmpeg.mergeAnyFiles(paths);
|
||||
await ffmpeg.mergeAnyFiles({ customOutDir, paths });
|
||||
} catch (err) {
|
||||
errorToast('Failed to merge files. Make sure they are all of the exact same format and codecs');
|
||||
console.error('Failed to merge files', err);
|
||||
@ -192,13 +193,12 @@ class App extends React.Component {
|
||||
});
|
||||
|
||||
electron.ipcRenderer.on('extract-all-streams', async () => {
|
||||
const { filePath } = this.state;
|
||||
const { filePath, customOutDir } = this.state;
|
||||
if (!filePath) return;
|
||||
|
||||
try {
|
||||
this.setState({ working: true });
|
||||
// TODO customOutDir ?
|
||||
await ffmpeg.extractAllStreams(filePath);
|
||||
await ffmpeg.extractAllStreams({ customOutDir, filePath });
|
||||
this.setState({ working: false });
|
||||
} catch (err) {
|
||||
errorToast('Failed to extract all streams');
|
||||
|
Loading…
Reference in New Issue
Block a user