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-08-06 00:54:31 +02:00
parent 94df449d12
commit 8a6dd62d6d
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26
2 changed files with 4 additions and 2 deletions

View File

@ -45,6 +45,8 @@ it('should format and parse duration with correct rounding', () => {
expect(formatDuration({ seconds: parseDuration('00:00:00,00', 30), fps: 30 })).toBe('00:00:00.00');
expect(formatDuration({ seconds: parseDuration('00:00:00,29', 30), fps: 30 })).toBe('00:00:00.29');
expect(formatDuration({ seconds: parseDuration('01:00:01,01', 30), fps: 30 })).toBe('01:00:01.01');
expect(parseDuration('0', 30)).toBe(0);
expect(parseDuration('0,1', 30)).toBe(0.03333333333333333);
});
// https://github.com/mifi/lossless-cut/issues/1603

View File

@ -40,7 +40,7 @@ export function formatDuration({ seconds: totalSecondsIn, fileNameFriendly, show
}
// todo adapt also to frame counts and frame fractions?
export const isExactDurationMatch = (str) => /^-?\d{2}:\d{2}:\d{2}.\d{3}$/.test(str);
export const isExactDurationMatch = (str: string) => /^-?\d{2}:\d{2}:\d{2}.\d{3}$/.test(str);
// See also parseYoutube
export function parseDuration(str: string, fps?: number) {
@ -60,7 +60,7 @@ export function parseDuration(str: string, fps?: number) {
sec = parseFloat(secWithFraction);
} else {
const [secStr, framesStr] = secWithFraction.split('.');
sec = parseInt(secStr!, 10) + parseInt(framesStr!, 10) / fps;
sec = parseInt(secStr!, 10) + (framesStr != null ? parseInt(framesStr, 10) : 0) / fps;
}
if (min > 59) return undefined;