diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts b/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts index c82970b88..3c2cf51b7 100644 --- a/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts +++ b/server/lib/live/shared/transcoding-wrapper/ffmpeg-transcoding-wrapper.ts | |||
@@ -10,6 +10,9 @@ import { AbstractTranscodingWrapper } from './abstract-transcoding-wrapper' | |||
10 | 10 | ||
11 | export class FFmpegTranscodingWrapper extends AbstractTranscodingWrapper { | 11 | export class FFmpegTranscodingWrapper extends AbstractTranscodingWrapper { |
12 | private ffmpegCommand: FfmpegCommand | 12 | private ffmpegCommand: FfmpegCommand |
13 | |||
14 | private aborted = false | ||
15 | private errored = false | ||
13 | private ended = false | 16 | private ended = false |
14 | 17 | ||
15 | async run () { | 18 | async run () { |
@@ -63,7 +66,12 @@ export class FFmpegTranscodingWrapper extends AbstractTranscodingWrapper { | |||
63 | } | 66 | } |
64 | 67 | ||
65 | abort () { | 68 | abort () { |
66 | // Nothing to do, ffmpeg will automatically exit | 69 | if (this.ended || this.errored || this.aborted) return |
70 | |||
71 | this.ffmpegCommand.kill('SIGINT') | ||
72 | |||
73 | this.aborted = true | ||
74 | this.emit('end') | ||
67 | } | 75 | } |
68 | 76 | ||
69 | private onFFmpegError (options: { | 77 | private onFFmpegError (options: { |
@@ -76,14 +84,16 @@ export class FFmpegTranscodingWrapper extends AbstractTranscodingWrapper { | |||
76 | 84 | ||
77 | // Don't care that we killed the ffmpeg process | 85 | // Don't care that we killed the ffmpeg process |
78 | if (err?.message?.includes('Exiting normally')) return | 86 | if (err?.message?.includes('Exiting normally')) return |
87 | if (this.ended || this.errored || this.aborted) return | ||
79 | 88 | ||
80 | logger.error('FFmpeg transcoding error.', { err, stdout, stderr, ffmpegShellCommand, ...this.lTags() }) | 89 | logger.error('FFmpeg transcoding error.', { err, stdout, stderr, ffmpegShellCommand, ...this.lTags() }) |
81 | 90 | ||
91 | this.errored = true | ||
82 | this.emit('error', { err }) | 92 | this.emit('error', { err }) |
83 | } | 93 | } |
84 | 94 | ||
85 | private onFFmpegEnded () { | 95 | private onFFmpegEnded () { |
86 | if (this.ended) return | 96 | if (this.ended || this.errored || this.aborted) return |
87 | 97 | ||
88 | this.ended = true | 98 | this.ended = true |
89 | this.emit('end') | 99 | this.emit('end') |