From 6bc5bb394f66aaf156e141f9284579a55cf5d8ad Mon Sep 17 00:00:00 2001 From: Mikael Finstad Date: Sat, 28 Aug 2021 14:21:52 +0700 Subject: [PATCH] commit forgotten code fixes #836 --- src/ffmpeg.js | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/ffmpeg.js b/src/ffmpeg.js index 034171f7..068fb293 100644 --- a/src/ffmpeg.js +++ b/src/ffmpeg.js @@ -313,21 +313,12 @@ function getPreferredCodecFormat({ codec_name: codec, codec_type: type }) { return undefined; } -// https://stackoverflow.com/questions/32922226/extract-every-audio-and-subtitles-from-a-video-with-ffmpeg -export async function extractStreams({ filePath, customOutDir, streams }) { - const outStreams = streams.map((s) => ({ - index: s.index, - codec: s.codec_name || s.codec_tag_string || s.codec_type, - type: s.codec_type, - format: getPreferredCodecFormat(s.codec_name, s.codec_type), - })) - .filter(it => it && it.format && it.index != null); +async function extractNonAttachmentStreams({ customOutDir, filePath, streams }) { + if (streams.length === 0) return; - // console.log(outStreams); + console.log('Extracting', streams.length, 'normal streams'); - const streamArgs = flatMap(outStreams, ({ - index, codec, type, format: { format, ext }, - }) => [ + const streamArgs = flatMap(streams, ({ index, codec, type, format: { format, ext } }) => [ '-map', `0:${index}`, '-c', 'copy', '-f', format, '-y', getOutPath(customOutDir, filePath, `stream-${index}-${type}-${codec}.${ext}`), ]);