mirror of
https://github.com/BluemediaGER/muse.git
synced 2024-11-12 21:05:29 +01:00
Kill FFMPEG after stream is closed (#582)
This commit is contained in:
parent
5497b22e49
commit
b206254c77
|
@ -5,6 +5,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||
|
||||
## [Unreleased]
|
||||
### Fixed
|
||||
- There are no longer FFMPEG orphan processes after listening to a livestream
|
||||
|
||||
## [1.6.1] - 2022-03-15
|
||||
### Fixed
|
||||
|
|
|
@ -527,14 +527,18 @@ export default class {
|
|||
capacitor.createReadStream().pipe(cacheStream);
|
||||
}
|
||||
|
||||
const returnedStream = capacitor.createReadStream();
|
||||
let hasReturnedStreamClosed = false;
|
||||
|
||||
const stream = ffmpeg(url)
|
||||
.inputOptions(options?.ffmpegInputOptions ?? ['-re'])
|
||||
.noVideo()
|
||||
.audioCodec('libopus')
|
||||
.outputFormat('webm')
|
||||
.on('error', error => {
|
||||
console.error(error);
|
||||
reject(error);
|
||||
if (!hasReturnedStreamClosed) {
|
||||
reject(error);
|
||||
}
|
||||
})
|
||||
.on('start', command => {
|
||||
debug(`Spawned ffmpeg with ${command as string}`);
|
||||
|
@ -542,7 +546,12 @@ export default class {
|
|||
|
||||
stream.pipe(capacitor);
|
||||
|
||||
resolve(capacitor.createReadStream());
|
||||
returnedStream.on('close', () => {
|
||||
stream.kill('SIGKILL');
|
||||
hasReturnedStreamClosed = true;
|
||||
});
|
||||
|
||||
resolve(returnedStream);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue