mirror of
https://github.com/stashapp/stash.git
synced 2025-12-18 04:44:37 +03:00
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:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user