add default subtitle codec too

pull/111/head
Mikael Finstad 2019-01-28 12:49:57 +01:00
rodzic 9dc15267c8
commit 461e909e47
1 zmienionych plików z 25 dodań i 24 usunięć

Wyświetl plik

@ -213,12 +213,7 @@ async function getAllStreams(filePath) {
return JSON.parse(result.stdout); return JSON.parse(result.stdout);
} }
// https://stackoverflow.com/questions/32922226/extract-every-audio-and-subtitles-from-a-video-with-ffmpeg function mapCodecToOutputFormat(codec, type) {
async function extractAllStreams(filePath) {
const { streams } = await getAllStreams(filePath);
console.log('streams', streams);
function mapCodecToOutputFormat(codec, type) {
const map = { const map = {
// See mapFormat // See mapFormat
m4a: { ext: 'm4a', format: 'ipod' }, m4a: { ext: 'm4a', format: 'ipod' },
@ -237,10 +232,16 @@ async function extractAllStreams(filePath) {
}; };
if (map[codec]) return map[codec]; if (map[codec]) return map[codec];
if (type === 'video') return { ext: 'mkv', format: 'mkv' }; if (type === 'video') return { ext: 'mkv', format: 'matroska' };
if (type === 'audio') return { ext: 'mkv', format: 'mkv' }; if (type === 'audio') return { ext: 'mka', format: 'matroska' };
if (type === 'subtitle') return { ext: 'mks', format: 'matroska' };
return undefined; return undefined;
} }
// https://stackoverflow.com/questions/32922226/extract-every-audio-and-subtitles-from-a-video-with-ffmpeg
async function extractAllStreams(filePath) {
const { streams } = await getAllStreams(filePath);
console.log('streams', streams);
const outStreams = streams.map((s, i) => ({ const outStreams = streams.map((s, i) => ({
i, i,