diff --git a/src/ffmpeg.js b/src/ffmpeg.js index f33ea19f..de853251 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -236,7 +236,7 @@ async function html5ifyDummy(filePath, outPath) { await transferTimestamps(filePath, outPath); } -async function mergeFiles({ paths, outPath }) { +async function mergeFiles({ paths, outPath, allStreams }) { console.log('Merging files', { paths }, 'to', outPath); // https://blog.yo1.dog/fix-for-ffmpeg-protocol-not-on-whitelist-error-for-urls/ @@ -244,7 +244,7 @@ async function mergeFiles({ paths, outPath }) { '-f', 'concat', '-safe', '0', '-protocol_whitelist', 'file,pipe', '-i', '-', '-c', 'copy', - '-map', '0', + ...(allStreams ? ['-map', '0'] : []), '-map_metadata', '0', // See https://github.com/mifi/lossless-cut/issues/170 @@ -269,11 +269,11 @@ async function mergeFiles({ paths, outPath }) { console.log(result.stdout); } -async function mergeAnyFiles({ customOutDir, paths }) { +async function mergeAnyFiles({ customOutDir, paths, allStreams }) { const firstPath = paths[0]; const ext = extname(firstPath); const outPath = getOutPath(customOutDir, firstPath, `merged${ext}`); - return mergeFiles({ paths, outPath }); + return mergeFiles({ paths, outPath, allStreams }); } async function autoMergeSegments({ customOutDir, sourceFile, segmentPaths }) { diff --git a/src/merge/merge.jsx b/src/merge/merge.jsx index e3a4f4dc..d0146d01 100644 --- a/src/merge/merge.jsx +++ b/src/merge/merge.jsx @@ -17,6 +17,7 @@ async function showMergeDialog(paths, onMergeClick) { let swalElem; let outPaths = paths; + let allStreams = false; const { dismiss } = await MySwal.fire({ width: '90%', showCancelButton: true, @@ -25,12 +26,13 @@ async function showMergeDialog(paths, onMergeClick) { html: ( { outPaths = val; }} + onAllStreamsChange={(val) => { allStreams = val; }} helperContainer={() => swalElem} />), }); if (!dismiss) { - onMergeClick(outPaths); + onMergeClick({ paths: outPaths, allStreams }); } } diff --git a/src/renderer.jsx b/src/renderer.jsx index 31cacea3..c2f612ad 100644 --- a/src/renderer.jsx +++ b/src/renderer.jsx @@ -416,13 +416,13 @@ const App = memo(() => { const offsetCurrentTime = (currentTime || 0) + startTimeOffset; - const mergeFiles = useCallback(async (paths) => { + const mergeFiles = useCallback(async ({ paths, allStreams }) => { try { setWorking(true); // console.log('merge', paths); await ffmpeg.mergeAnyFiles({ - customOutDir, paths, + customOutDir, paths, allStreams, }); } catch (err) { errorToast('Failed to merge files. Make sure they are all of the exact same format and codecs');