diff options
Diffstat (limited to 'packages/peertube-runner')
-rw-r--r-- | packages/peertube-runner/server/process/shared/common.ts | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/packages/peertube-runner/server/process/shared/common.ts b/packages/peertube-runner/server/process/shared/common.ts index 88f7c33f1..dbeb9dfc1 100644 --- a/packages/peertube-runner/server/process/shared/common.ts +++ b/packages/peertube-runner/server/process/shared/common.ts | |||
@@ -1,5 +1,4 @@ | |||
1 | import { remove } from 'fs-extra' | 1 | import { remove } from 'fs-extra' |
2 | import { throttle } from 'lodash' | ||
3 | import { ConfigManager, downloadFile, logger } from 'packages/peertube-runner/shared' | 2 | import { ConfigManager, downloadFile, logger } from 'packages/peertube-runner/shared' |
4 | import { join } from 'path' | 3 | import { join } from 'path' |
5 | import { buildUUID } from '@shared/extra-utils' | 4 | import { buildUUID } from '@shared/extra-utils' |
@@ -60,17 +59,26 @@ export function buildFFmpegVOD (options: { | |||
60 | ? 500 | 59 | ? 500 |
61 | : 60000 | 60 | : 60000 |
62 | 61 | ||
63 | const updateJobProgress = throttle((progress: number) => { | 62 | let progress: number |
64 | if (progress < 0 || progress > 100) progress = undefined | ||
65 | 63 | ||
64 | const interval = setInterval(() => { | ||
66 | updateTranscodingProgress({ server, job, runnerToken, progress }) | 65 | updateTranscodingProgress({ server, job, runnerToken, progress }) |
67 | .catch(err => logger.error({ err }, 'Cannot send job progress')) | 66 | .catch(err => logger.error({ err }, 'Cannot send job progress')) |
68 | }, updateInterval, { trailing: false }) | 67 | }, updateInterval) |
69 | 68 | ||
70 | return new FFmpegVOD({ | 69 | return new FFmpegVOD({ |
71 | ...getCommonFFmpegOptions(), | 70 | ...getCommonFFmpegOptions(), |
72 | 71 | ||
73 | updateJobProgress | 72 | onError: () => clearInterval(interval), |
73 | onEnd: () => clearInterval(interval), | ||
74 | |||
75 | updateJobProgress: arg => { | ||
76 | if (arg < 0 || arg > 100) { | ||
77 | progress = undefined | ||
78 | } else { | ||
79 | progress = arg | ||
80 | } | ||
81 | } | ||
74 | }) | 82 | }) |
75 | } | 83 | } |
76 | 84 | ||