Added stream selection by hostname, improved config structure.
This commit is contained in:
parent
5bbfbc90a8
commit
85a5f13ec1
|
|
@ -416,11 +416,14 @@ module.exports = {
|
|||
trailerQuality: [540, 720, 960, 480, 1080, 360, 320, 1440, 1600, 1920, 2160, 270, 240, 180],
|
||||
limit: 25, // max number of photos per release
|
||||
attempts: 2,
|
||||
fetchStreams: true,
|
||||
streamConcurrency: 2, // max number of video streams (m3u8 etc.) to fetch and process at once
|
||||
streamExcludeHostnames: [], // resource hogs
|
||||
flushOrphaned: true,
|
||||
flushWindow: 1000,
|
||||
streams: {
|
||||
enabled: true, // fetch streams
|
||||
concurrency: 2,
|
||||
excludeHostnames: [],
|
||||
selectIndex: {},
|
||||
},
|
||||
},
|
||||
titleSlugLength: 50,
|
||||
};
|
||||
|
|
|
|||
14
src/media.js
14
src/media.js
|
|
@ -671,16 +671,20 @@ async function fetchHttpSource(source, tempFileTarget, hashStream) {
|
|||
|
||||
streamQueue.define('fetchStreamSource', async ({ source, tempFileTarget, hashStream }) => {
|
||||
const meta = { mimetype: 'video/mp4' };
|
||||
|
||||
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`);
|
||||
}
|
||||
|
||||
const streamIndex = config.media.streams.selectIndex[hostname];
|
||||
|
||||
const command = ffmpeg(source.stream)
|
||||
.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}"`));
|
||||
|
||||
const video = command.pipe();
|
||||
|
|
@ -706,7 +710,7 @@ streamQueue.define('fetchStreamSource', async ({ source, tempFileTarget, hashStr
|
|||
|
||||
return meta;
|
||||
}, {
|
||||
concurrency: config.media.streamConcurrency,
|
||||
concurrency: config.media.streams.concurrency,
|
||||
});
|
||||
|
||||
async function fetchSource(source, baseMedia) {
|
||||
|
|
@ -715,7 +719,7 @@ async function fetchSource(source, baseMedia) {
|
|||
logger.silly(`Fetching media from ${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}`);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue