improve extract png/jpg streams

pull/1457/head
Mikael Finstad 3 years ago
parent 3c46486cf3
commit 1b3811a786
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -5,7 +5,7 @@ import i18n from 'i18next';
import Timecode from 'smpte-timecode'; import Timecode from 'smpte-timecode';
import { pcmAudioCodecs, getMapStreamsArgs, isMov } from './util/streams'; import { pcmAudioCodecs, getMapStreamsArgs, isMov } from './util/streams';
import { getSuffixedOutPath, getExtensionForFormat, isWindows, isMac, platform, arch, isExecaFailure } from './util'; import { getSuffixedOutPath, isWindows, isMac, platform, arch, isExecaFailure } from './util';
import { isDurationValid } from './segments'; import { isDurationValid } from './segments';
import isDev from './isDev'; import isDev from './isDev';
@ -374,31 +374,34 @@ export async function readFileMeta(filePath) {
} }
function getPreferredCodecFormat({ codec_name: codec, codec_type: type }) { function getPreferredCodecFormat(stream) {
const map = { const map = {
mp3: 'mp3', mp3: { format: 'mp3', ext: 'mp3' },
opus: 'opus', opus: { format: 'opus', ext: 'opus' },
vorbis: 'ogg', vorbis: { format: 'ogg', ext: 'ogg' },
h264: 'mp4', h264: { format: 'mp4', ext: 'mp4' },
hevc: 'mp4', hevc: { format: 'mp4', ext: 'mp4' },
eac3: 'eac3', eac3: { format: 'eac3', ext: 'eac3' },
subrip: 'srt', subrip: { format: 'srt', ext: 'srt' },
// See mapFormat m4a: { format: 'ipod', ext: 'm4a' },
m4a: 'ipod', aac: { format: 'adts', ext: 'aac' },
aac: 'adts', jpeg: { format: 'image2', ext: 'jpeg' },
png: { format: 'image2', ext: 'png' },
// TODO add more // TODO add more
// TODO allow user to change? // TODO allow user to change?
}; };
const format = map[codec]; const match = map[stream.codec_name];
if (format) return { ext: getExtensionForFormat(format), format }; if (match) return match;
if (type === 'video') return { ext: 'mkv', format: 'matroska' };
if (type === 'audio') return { ext: 'mka', format: 'matroska' }; // default fallbacks:
if (type === 'subtitle') return { ext: 'mks', format: 'matroska' }; if (stream.codec_type === 'video') return { ext: 'mkv', format: 'matroska' };
if (type === 'data') return { ext: 'bin', format: 'data' }; // https://superuser.com/questions/1243257/save-data-stream if (stream.codec_type === 'audio') return { ext: 'mka', format: 'matroska' };
if (stream.codec_type === 'subtitle') return { ext: 'mks', format: 'matroska' };
if (stream.codec_type === 'data') return { ext: 'bin', format: 'data' }; // https://superuser.com/questions/1243257/save-data-stream
return undefined; return undefined;
} }

Loading…
Cancel
Save