mirror of
https://github.com/BluemediaDev/muse.git
synced 2025-04-19 12:53:56 +02:00
Kill FFMPEG after stream is closed (#582)
This commit is contained in:
parent
5497b22e49
commit
b206254c77
2 changed files with 14 additions and 3 deletions
|
@ -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).
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
||||||
|
|
||||||
## [Unreleased]
|
## [Unreleased]
|
||||||
|
### Fixed
|
||||||
|
- There are no longer FFMPEG orphan processes after listening to a livestream
|
||||||
|
|
||||||
## [1.6.1] - 2022-03-15
|
## [1.6.1] - 2022-03-15
|
||||||
### Fixed
|
### Fixed
|
||||||
|
|
|
@ -527,14 +527,18 @@ export default class {
|
||||||
capacitor.createReadStream().pipe(cacheStream);
|
capacitor.createReadStream().pipe(cacheStream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const returnedStream = capacitor.createReadStream();
|
||||||
|
let hasReturnedStreamClosed = false;
|
||||||
|
|
||||||
const stream = ffmpeg(url)
|
const stream = ffmpeg(url)
|
||||||
.inputOptions(options?.ffmpegInputOptions ?? ['-re'])
|
.inputOptions(options?.ffmpegInputOptions ?? ['-re'])
|
||||||
.noVideo()
|
.noVideo()
|
||||||
.audioCodec('libopus')
|
.audioCodec('libopus')
|
||||||
.outputFormat('webm')
|
.outputFormat('webm')
|
||||||
.on('error', error => {
|
.on('error', error => {
|
||||||
console.error(error);
|
if (!hasReturnedStreamClosed) {
|
||||||
reject(error);
|
reject(error);
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.on('start', command => {
|
.on('start', command => {
|
||||||
debug(`Spawned ffmpeg with ${command as string}`);
|
debug(`Spawned ffmpeg with ${command as string}`);
|
||||||
|
@ -542,7 +546,12 @@ export default class {
|
||||||
|
|
||||||
stream.pipe(capacitor);
|
stream.pipe(capacitor);
|
||||||
|
|
||||||
resolve(capacitor.createReadStream());
|
returnedStream.on('close', () => {
|
||||||
|
stream.kill('SIGKILL');
|
||||||
|
hasReturnedStreamClosed = true;
|
||||||
|
});
|
||||||
|
|
||||||
|
resolve(returnedStream);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue