1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-25 03:33:14 +01:00
This commit is contained in:
Mikael Finstad 2024-02-12 14:36:34 +08:00
parent f1f469f8c7
commit ddf3eb22e0
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
12 changed files with 705 additions and 523 deletions

View File

@ -102,7 +102,7 @@
"use-trace-update": "^1.3.0",
"uuid": "^8.3.2",
"vite": "^4.5.2",
"vitest": "^0.28.5",
"vitest": "^1.2.2",
"wait-on": "^7.0.1"
},
"dependencies": {

View File

@ -1,4 +1,4 @@
// Vitest Snapshot v1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`format srt 1`] = `
"1

View File

@ -1,4 +1,4 @@
// Vitest Snapshot v1
// Vitest Snapshot v1, https://vitest.dev/guide/snapshot.html
exports[`converts segments to chapters with gaps 1`] = `
[

View File

@ -9,7 +9,8 @@ import { parseSrt, formatSrt, parseYouTube, formatYouTube, parseMplayerEdl, pars
// eslint-disable-next-line no-underscore-dangle
const __dirname = dirname(fileURLToPath(import.meta.url));
const readFixture = async (name, encoding = 'utf-8') => fs.readFile(join(__dirname, 'fixtures', name), encoding);
const readFixture = async (name: string, encoding: BufferEncoding = 'utf-8') => fs.readFile(join(__dirname, 'fixtures', name), encoding);
const readFixtureBinary = async (name: string) => fs.readFile(join(__dirname, 'fixtures', name), null);
const expectYouTube1 = [
{ start: 0, end: 1, name: '00:01 Test 1' },
@ -242,10 +243,10 @@ it('parses csv with timestamps', async () => {
});
it('parses pbf', async () => {
expect(parsePbf(await readFixture('test1.pbf', null))).toMatchSnapshot();
expect(parsePbf(await readFixture('test2.pbf', null))).toMatchSnapshot();
expect(parsePbf(await readFixture('test3.pbf', null))).toMatchSnapshot();
expect(parsePbf(await readFixture('potplayer bookmark format utf16le issue 867.pbf', null))).toMatchSnapshot();
expect(parsePbf(await readFixtureBinary('test1.pbf'))).toMatchSnapshot();
expect(parsePbf(await readFixtureBinary('test2.pbf'))).toMatchSnapshot();
expect(parsePbf(await readFixtureBinary('test3.pbf'))).toMatchSnapshot();
expect(parsePbf(await readFixtureBinary('potplayer bookmark format utf16le issue 867.pbf'))).toMatchSnapshot();
});
it('parses srt', async () => {

View File

@ -299,7 +299,7 @@ export function parseDvAnalyzerSummaryTxt(txt: string) {
// http://www.textfiles.com/uploads/kds-srt.txt
export function parseSrt(text: string) {
const ret: { start?: number, end?: number, name: string, tags: Record<string, string> }[] = [];
const ret: { start?: number, end?: number, name: string, tags: Record<string, string | number | undefined> }[] = [];
// working state
let subtitleIndexAt: number | undefined;
@ -309,7 +309,7 @@ export function parseSrt(text: string) {
const flush = () => {
if (start != null && end != null && lines.length > 0) {
ret.push({ start, end, name: lines.join('\r\n'), tags: { index: String(subtitleIndexAt) } });
ret.push({ start, end, name: lines.join('\r\n'), tags: { index: subtitleIndexAt } });
}
start = undefined;
end = undefined;

1
src/global.d.ts vendored Normal file
View File

@ -0,0 +1 @@
declare module '*.module.css';

View File

@ -84,7 +84,7 @@ test('getMapStreamsArgs, smart cut', () => {
if (streamIndex === 2) {
return [
`-c:${outputIndex}`, 'h264',
`-b:${outputIndex}`, 123456789,
`-b:${outputIndex}`, '123456789',
];
}
return undefined;
@ -94,7 +94,7 @@ test('getMapStreamsArgs, smart cut', () => {
'-c:0', 'copy',
'-map', '0:2',
'-c:1', 'h264',
'-b:1', 123456789,
'-b:1', '123456789',
'-map', '0:4',
'-c:2', 'copy',
'-map', '0:5',

View File

@ -108,8 +108,10 @@ export function getActiveDisposition(disposition) {
export const isMov = (format) => ['ismv', 'ipod', 'mp4', 'mov'].includes(format);
type GetVideoArgsFn = (a: { streamIndex: number, outputIndex: number }) => string[] | undefined;
function getPerStreamFlags({ stream, outputIndex, outFormat, manuallyCopyDisposition = false, getVideoArgs = () => undefined }: {
stream, outputIndex: number, outFormat: string, manuallyCopyDisposition?: boolean, getVideoArgs?: (a: { streamIndex: number, outputIndex: number }) => string[] | undefined
stream, outputIndex: number, outFormat: string, manuallyCopyDisposition?: boolean, getVideoArgs?: GetVideoArgsFn
}) {
let args: string[] = [];
@ -190,7 +192,9 @@ function getPerStreamFlags({ stream, outputIndex, outFormat, manuallyCopyDisposi
return args;
}
export function getMapStreamsArgs({ startIndex = 0, outFormat, allFilesMeta, copyFileStreams, manuallyCopyDisposition, getVideoArgs }) {
export function getMapStreamsArgs({ startIndex = 0, outFormat, allFilesMeta, copyFileStreams, manuallyCopyDisposition, getVideoArgs }: {
startIndex?: number, outFormat: string, allFilesMeta, copyFileStreams: { streamIds: number[], path: string }[], manuallyCopyDisposition?: boolean, getVideoArgs?: GetVideoArgsFn,
}) {
let args: string[] = [];
let outputIndex = startIndex;

1194
yarn.lock

File diff suppressed because it is too large Load Diff