Overhaul HLS streaming (#3274)

* Overhaul HLS streaming
* Fix streaming transcode ffmpeg zombie processes
* Add changelog and release notes
* Documentation
---------
Co-authored-by: WithoutPants <53250216+WithoutPants@users.noreply.github.com>
This commit is contained in:
DingDongSoLong4
2023-02-24 05:55:46 +02:00
committed by GitHub
parent f767635080
commit 05669f5503
16 changed files with 1219 additions and 580 deletions

View File

@@ -108,8 +108,9 @@ type Manager struct {
Paths *paths.Paths
FFMPEG ffmpeg.FFMpeg
FFProbe ffmpeg.FFProbe
FFMPEG ffmpeg.FFMpeg
FFProbe ffmpeg.FFProbe
StreamManager *ffmpeg.StreamManager
ReadLockManager *fsutil.ReadLockManager
@@ -430,6 +431,7 @@ func initFFMPEG(ctx context.Context) error {
instance.FFMPEG = ffmpeg.FFMpeg(ffmpegPath)
instance.FFProbe = ffmpeg.FFProbe(ffprobePath)
instance.RefreshStreamManager()
}
return nil
@@ -564,6 +566,19 @@ func (s *Manager) RefreshScraperCache() {
s.ScraperCache = s.initScraperCache()
}
// RefreshStreamManager refreshes the stream manager. Call this when cache directory
// changes.
func (s *Manager) RefreshStreamManager() {
// shutdown existing manager if needed
if s.StreamManager != nil {
s.StreamManager.Shutdown()
s.StreamManager = nil
}
cacheDir := s.Config.GetCachePath()
s.StreamManager = ffmpeg.NewStreamManager(cacheDir, s.FFMPEG, s.FFProbe, s.Config, s.ReadLockManager)
}
func setSetupDefaults(input *SetupInput) {
if input.ConfigLocation == "" {
input.ConfigLocation = filepath.Join(fsutil.GetHomeDirectory(), ".stash", "config.yml")
@@ -735,6 +750,11 @@ func (s *Manager) Shutdown(code int) {
// stop any profiling at exit
pprof.StopCPUProfile()
if s.StreamManager != nil {
s.StreamManager.Shutdown()
s.StreamManager = nil
}
// TODO: Each part of the manager needs to gracefully stop at some point
// for now, we just close the database.
err := s.Database.Close()