feat: add thumbnail timeout and low-memory warning

This commit is contained in:
tianmo committed 2026-10-17 16:19:18 +08:00
1 parent 7b2fae6335
commit 76328fa058
10 files changed
+196 -17

No files matched your search

+14 -1
View File
@@ -4,6 +4,7 @@ import { join } from 'node:path'
import { describe, expect, it } from 'vitest'
import {
cleanupExpiredHlsDownloads,
buildThumbnailFfmpegArgs,
DEFAULT_TRANSCODE_CONCURRENCY,
DEFAULT_TRANSCODE_PRESET,
DEFAULT_TRANSCODE_THREADS,
@@ -15,7 +16,8 @@ import {
parseTranscodePreset,
setTranscodeSettings,
summarizeTranscodeFailure,
thumbKeyFor
thumbKeyFor,
THUMBNAIL_FFMPEG_TIMEOUT_MS
} from './transcode'
import { isVideoSidecarKey, mediaTypeForKey } from './image-key'
@@ -28,6 +30,17 @@ describe('hlsPlaylistKey', () => {
})
})
describe('thumbnail ffmpeg args', () => {
it('limits thumbnail extraction to one worker and one filter thread', () => {
const args = buildThumbnailFfmpegArgs('/tmp/input.mp4', '/tmp/thumb.png', 1)
expect(args.slice(args.indexOf('-threads'), args.indexOf('-threads') + 2))
.toEqual(['-threads', '1'])
expect(args.slice(args.indexOf('-filter_threads'), args.indexOf('-filter_threads') + 2))
.toEqual(['-filter_threads', '1'])
expect(THUMBNAIL_FFMPEG_TIMEOUT_MS).toBe(10_000)
})
})
describe('isVideoSidecarKey', () => {
it('detects playlists, segments and thumbnails', () => {
expect(isVideoSidecarKey('videos/2026/10/abc/index.m3u8')).toBe(true)