1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00

convert more subtitle codecs #418

This commit is contained in:
Mikael Finstad 2023-12-21 16:25:09 +08:00
parent b1f611099c
commit 1a574c02b2
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
2 changed files with 36 additions and 0 deletions

View File

@ -131,6 +131,12 @@ function getPerStreamFlags({ stream, outputIndex, outFormat, manuallyCopyDisposi
} else if (outFormat === 'webm' && stream.codec_name === 'mov_text') {
// Only WebVTT subtitles are supported for WebM.
addCodecArgs('webvtt');
} else if (outFormat === 'srt') { // not technically lossless but why not
addCodecArgs('srt');
} else if (outFormat === 'ass') { // not technically lossless but why not
addCodecArgs('ass');
} else if (outFormat === 'webvtt') { // not technically lossless but why not
addCodecArgs('webvtt');
} else {
addCodecArgs('copy');
}

View File

@ -111,3 +111,33 @@ test('getStreamIdsToCopy, includeAllStreams false', () => {
expect(streamIdsToCopy).toEqual([2, 1, 7]);
expect(excludedStreamIds).toEqual([0, 3, 4, 5, 6]);
});
test('srt output', () => {
expect(getMapStreamsArgs({
allFilesMeta: { [path]: { streams: [{ index: 0, codec_type: 'subtitle', codec_tag: '0x67337874', codec_name: 'mov_text' }] } },
copyFileStreams: [{ path, streamIds: [0] }],
outFormat: 'srt',
})).toEqual([
'-map', '0:0', '-c:0', 'srt',
]);
});
test('webvtt output', () => {
expect(getMapStreamsArgs({
allFilesMeta: { [path]: { streams: [{ index: 0, codec_type: 'subtitle', codec_tag: '0x67337874', codec_name: 'mov_text' }] } },
copyFileStreams: [{ path, streamIds: [0] }],
outFormat: 'webvtt',
})).toEqual([
'-map', '0:0', '-c:0', 'webvtt',
]);
});
test('ass output', () => {
expect(getMapStreamsArgs({
allFilesMeta: { [path]: { streams: [{ index: 0, codec_type: 'subtitle', codec_tag: '0x67337874', codec_name: 'mov_text' }] } },
copyFileStreams: [{ path, streamIds: [0] }],
outFormat: 'ass',
})).toEqual([
'-map', '0:0', '-c:0', 'ass',
]);
});