mirror of
https://github.com/mifi/lossless-cut.git
synced 2024-11-25 03:33:14 +01:00
fix bug
This commit is contained in:
parent
94df449d12
commit
8a6dd62d6d
@ -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
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user