Rewrite HLS segmentation algo AGAIN, add a bunch of HLS segmentation tests, add VideoEncoder/AudioEncoder timing refinement logic, fix HLS output spec violations

This commit is contained in:
Vanilagy
2026-03-26 16:23:07 +01:00
parent 157582498f
commit 5bc1a31b8e
10 changed files with 1235 additions and 135 deletions
+14 -1
View File
@@ -1,7 +1,7 @@
import { expect, test } from 'vitest';
import { joinPaths } from '../../src/misc.js';
test('joinPaths handles all path combinations correctly', () => {
test('joinPaths', () => {
// Simple relative paths
expect(joinPaths('path/to/entry.m3u8', 'other.m3u8')).toBe('path/to/other.m3u8');
expect(joinPaths('entry.m3u8', 'other.m3u8')).toBe('other.m3u8');
@@ -36,6 +36,19 @@ test('joinPaths handles all path combinations correctly', () => {
expect(joinPaths('path/to/entry.m3u8', './../other.m3u8')).toBe('path/other.m3u8');
expect(joinPaths('path/to/entry.m3u8', '../foo/../other.m3u8')).toBe('path/other.m3u8');
// URL base path with query parameters
expect(joinPaths('https://example.com/path/to/entry.m3u8?token=abc', 'other.m3u8'))
.toBe('https://example.com/path/to/other.m3u8');
expect(joinPaths('https://example.com/path/to/entry.m3u8?redirect=/foo/bar', 'other.m3u8'))
.toBe('https://example.com/path/to/other.m3u8');
expect(joinPaths('https://example.com/path/to/entry.m3u8?token=abc', '/other.m3u8'))
.toBe('https://example.com/other.m3u8');
expect(joinPaths('https://example.com/path/to/entry.m3u8?token=abc', '../other.m3u8'))
.toBe('https://example.com/path/other.m3u8');
// Filesystem paths with ? in the name are preserved
expect(joinPaths('path/to/sus?directory/file.m3u8', 'other.m3u8')).toBe('path/to/sus?directory/other.m3u8');
// Second argument is a full URL with protocol
expect(joinPaths('path/to/entry.m3u8', 'https://example.com/other.m3u8'))
.toBe('https://example.com/other.m3u8');