Nice ffmpeg to 15 and 2

Niceness 15 for video conversionNiceness 2 for image generation
(niceness 2 doesn't make it slower, just don't block servers and other
app)
pull/901/head
Jorropo 2018-07-27 11:45:05 +02:00 committed by Chocobozzz
parent 4a5ccac5f1
commit 80bc88c133
2 changed files with 9 additions and 3 deletions

View File

@ -1,7 +1,7 @@
import * as ffmpeg from 'fluent-ffmpeg' import * as ffmpeg from 'fluent-ffmpeg'
import { join } from 'path' import { join } from 'path'
import { VideoResolution } from '../../shared/models/videos' import { VideoResolution } from '../../shared/models/videos'
import { CONFIG, VIDEO_TRANSCODING_FPS } from '../initializers' import { CONFIG, VIDEO_TRANSCODING_FPS, FFMPEG_NICE } from '../initializers'
import { unlinkPromise } from './core-utils' import { unlinkPromise } from './core-utils'
import { processImage } from './image-utils' import { processImage } from './image-utils'
import { logger } from './logger' import { logger } from './logger'
@ -56,7 +56,7 @@ async function generateImageFromVideoFile (fromPath: string, folder: string, ima
try { try {
await new Promise<string>((res, rej) => { await new Promise<string>((res, rej) => {
ffmpeg(fromPath) ffmpeg(fromPath, { 'niceness': FFMPEG_NICE.THUMBNAIL })
.on('error', rej) .on('error', rej)
.on('end', () => res(imageName)) .on('end', () => res(imageName))
.thumbnail(options) .thumbnail(options)
@ -84,7 +84,7 @@ type TranscodeOptions = {
function transcode (options: TranscodeOptions) { function transcode (options: TranscodeOptions) {
return new Promise<void>(async (res, rej) => { return new Promise<void>(async (res, rej) => {
let command = ffmpeg(options.inputPath) let command = ffmpeg(options.inputPath, { 'niceness': FFMPEG_NICE.TRANSCODING })
.output(options.outputPath) .output(options.outputPath)
.outputOption('-threads ' + CONFIG.TRANSCODING.THREADS) .outputOption('-threads ' + CONFIG.TRANSCODING.THREADS)
.renice(5) // we don't want to make the system unrepsonsive .renice(5) // we don't want to make the system unrepsonsive

View File

@ -316,6 +316,11 @@ const VIDEO_RATE_TYPES: { [ id: string ]: VideoRateType } = {
DISLIKE: 'dislike' DISLIKE: 'dislike'
} }
const FFMPEG_NICE: { [ id: string ]: number } = {
THUMBNAIL: 2, // 2 just for don't blocking servers
TRANSCODING: 15
}
const VIDEO_CATEGORIES = { const VIDEO_CATEGORIES = {
1: 'Music', 1: 'Music',
2: 'Films', 2: 'Films',
@ -570,6 +575,7 @@ export {
VIDEO_RATE_TYPES, VIDEO_RATE_TYPES,
VIDEO_MIMETYPE_EXT, VIDEO_MIMETYPE_EXT,
VIDEO_TRANSCODING_FPS, VIDEO_TRANSCODING_FPS,
FFMPEG_NICE,
JOB_REQUEST_TIMEOUT, JOB_REQUEST_TIMEOUT,
JOB_REQUEST_TTL, JOB_REQUEST_TTL,
USER_PASSWORD_RESET_LIFETIME, USER_PASSWORD_RESET_LIFETIME,