include all streams also in merge #227

pull/196/head
Mikael Finstad 7 years ago
parent 2322e54175
commit ee3d7eb6ae

@ -216,14 +216,20 @@ async function html5ifyDummy(filePath, outPath) {
await transferTimestamps(filePath, outPath);
}
async function mergeFiles(paths, outPath) {
async function mergeFiles({ paths, outPath, includeAllStreams }) {
console.log('Merging files', { paths }, 'to', outPath);
// https://blog.yo1.dog/fix-for-ffmpeg-protocol-not-on-whitelist-error-for-urls/
const ffmpegArgs = [
'-f', 'concat', '-safe', '0', '-protocol_whitelist', 'file,pipe', '-i', '-',
'-c', 'copy',
...(includeAllStreams ? ['-map', '0'] : []),
'-map_metadata', '0',
// See https://github.com/mifi/lossless-cut/issues/170
'-ignore_unknown',
'-y', outPath,
];
@ -243,17 +249,17 @@ async function mergeFiles(paths, outPath) {
console.log(result.stdout);
}
async function mergeAnyFiles({ customOutDir, paths }) {
async function mergeAnyFiles({ customOutDir, paths, includeAllStreams }) {
const firstPath = paths[0];
const ext = path.extname(firstPath);
const outPath = getOutPath(customOutDir, firstPath, `merged${ext}`);
return mergeFiles(paths, outPath);
return mergeFiles({ paths, outPath, includeAllStreams });
}
async function autoMergeSegments({ customOutDir, sourceFile, segmentPaths }) {
async function autoMergeSegments({ customOutDir, sourceFile, segmentPaths, includeAllStreams }) {
const ext = path.extname(sourceFile);
const outPath = getOutPath(customOutDir, sourceFile, `cut-merged-${new Date().getTime()}${ext}`);
await mergeFiles(segmentPaths, outPath);
await mergeFiles({ paths: segmentPaths, outPath, includeAllStreams });
await bluebird.map(segmentPaths, trash, { concurrency: 5 });
}

@ -365,10 +365,10 @@ class App extends React.Component {
try {
this.setState({ working: true });
const { customOutDir } = this.state;
const { customOutDir, includeAllStreams } = this.state;
// console.log('merge', paths);
await ffmpeg.mergeAnyFiles({ customOutDir, paths });
await ffmpeg.mergeAnyFiles({ customOutDir, paths, includeAllStreams });
} 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);
@ -561,6 +561,7 @@ class App extends React.Component {
customOutDir,
sourceFile: filePath,
segmentPaths: outFiles,
includeAllStreams,
});
}
} catch (err) {

Loading…
Cancel
Save