1 import { logger } from '@server/helpers/logger'
2 import { CONFIG } from '@server/initializers/config'
3 import { FFMPEG_NICE } from '@server/initializers/constants'
4 import { FFmpegCommandWrapperOptions } from '@shared/ffmpeg'
5 import { AvailableEncoders } from '@shared/models'
7 type CommandType = 'live' | 'vod' | 'thumbnail'
9 export function getFFmpegCommandWrapperOptions (type: CommandType, availableEncoders?: AvailableEncoders): FFmpegCommandWrapperOptions {
12 profile: getProfile(type),
14 niceness: FFMPEG_NICE[type.toUpperCase()],
15 tmpDirectory: CONFIG.STORAGE.TMP_DIR,
16 threads: getThreads(type),
19 debug: logger.debug.bind(logger),
20 info: logger.info.bind(logger),
21 warn: logger.warn.bind(logger),
22 error: logger.error.bind(logger)
24 lTags: { tags: [ 'ffmpeg' ] }
28 // ---------------------------------------------------------------------------
30 // ---------------------------------------------------------------------------
32 function getThreads (type: CommandType) {
33 if (type === 'live') return CONFIG.LIVE.TRANSCODING.THREADS
34 if (type === 'vod') return CONFIG.TRANSCODING.THREADS
40 function getProfile (type: CommandType) {
41 if (type === 'live') return CONFIG.LIVE.TRANSCODING.PROFILE
42 if (type === 'vod') return CONFIG.TRANSCODING.PROFILE