Added stream selection by hostname, improved config structure.

This commit is contained in:
DebaucheryLibrarian 2026-02-08 03:51:41 +01:00
parent 5bbfbc90a8
commit 85a5f13ec1
2 changed files with 15 additions and 8 deletions

View File

@ -416,11 +416,14 @@ module.exports = {
trailerQuality: [540, 720, 960, 480, 1080, 360, 320, 1440, 1600, 1920, 2160, 270, 240, 180], trailerQuality: [540, 720, 960, 480, 1080, 360, 320, 1440, 1600, 1920, 2160, 270, 240, 180],
limit: 25, // max number of photos per release limit: 25, // max number of photos per release
attempts: 2, attempts: 2,
fetchStreams: true,
streamConcurrency: 2, // max number of video streams (m3u8 etc.) to fetch and process at once
streamExcludeHostnames: [], // resource hogs
flushOrphaned: true, flushOrphaned: true,
flushWindow: 1000, flushWindow: 1000,
streams: {
enabled: true, // fetch streams
concurrency: 2,
excludeHostnames: [],
selectIndex: {},
},
}, },
titleSlugLength: 50, titleSlugLength: 50,
}; };

View File

@ -671,16 +671,20 @@ async function fetchHttpSource(source, tempFileTarget, hashStream) {
streamQueue.define('fetchStreamSource', async ({ source, tempFileTarget, hashStream }) => { streamQueue.define('fetchStreamSource', async ({ source, tempFileTarget, hashStream }) => {
const meta = { mimetype: 'video/mp4' }; const meta = { mimetype: 'video/mp4' };
const { hostname } = new URL(source.stream); const { hostname } = new URL(source.stream);
if (config.media.streamExcludeHostnames.includes(hostname)) { if (config.media.streams.excludeHostnames.includes(hostname)) {
throw new Error(`Stream source hostname ${hostname} is excluded by config`); throw new Error(`Stream source hostname ${hostname} is excluded by config`);
} }
const streamIndex = config.media.streams.selectIndex[hostname];
const command = ffmpeg(source.stream) const command = ffmpeg(source.stream)
.format('mp4') .format('mp4')
.outputOptions(['-movflags frag_keyframe+empty_moov']) .outputOptions([
'-movflags frag_keyframe+empty_moov',
...(typeof streamIndex === 'number' ? [`-map p:${streamIndex}`] : []),
])
.on('start', (cmd) => logger.verbose(`Fetching stream from ${source.stream} with "${cmd}"`)); .on('start', (cmd) => logger.verbose(`Fetching stream from ${source.stream} with "${cmd}"`));
const video = command.pipe(); const video = command.pipe();
@ -706,7 +710,7 @@ streamQueue.define('fetchStreamSource', async ({ source, tempFileTarget, hashStr
return meta; return meta;
}, { }, {
concurrency: config.media.streamConcurrency, concurrency: config.media.streams.concurrency,
}); });
async function fetchSource(source, baseMedia) { async function fetchSource(source, baseMedia) {
@ -715,7 +719,7 @@ async function fetchSource(source, baseMedia) {
logger.silly(`Fetching media from ${source.src}`); logger.silly(`Fetching media from ${source.src}`);
logger.debug(`Memory usage before media fetch: ${process.memoryUsage.rss() / 1000000} MB (${source.src})`); logger.debug(`Memory usage before media fetch: ${process.memoryUsage.rss() / 1000000} MB (${source.src})`);
if (source.stream && !config.media.fetchStreams) { if (source.stream && !config.media.streams.enabled) {
throw new Error(`Stream fetching disabled, ignoring ${source.stream}`); throw new Error(`Stream fetching disabled, ignoring ${source.stream}`);
} }