streamd: copyable m3u8 links + FHD/HD/SD output variants
Some checks failed
release / build-and-upload (push) Failing after 3m33s
Some checks failed
release / build-and-upload (push) Failing after 3m33s
- WebUI Copy button for absolute m3u8 URLs (no player) - Per-stream variants ladder; HD/SD live-transcoded as sibling HLS - variants_json in DB/API; supervisor spawns scaled ffmpeg packagers
This commit is contained in:
parent
ac8701b5a6
commit
3cb259c9b6
12 changed files with 913 additions and 62 deletions
|
|
@ -49,6 +49,8 @@ type streamProc struct {
|
|||
mpdProxy *mpd.LocalServer
|
||||
nreDead bool
|
||||
ffDead bool
|
||||
variants []*variantProc
|
||||
variantSpecs []db.VariantSpec
|
||||
// tsReadyBytes is how much muxed output to buffer before probing, from the
|
||||
// stream's app module.
|
||||
tsReadyBytes int64
|
||||
|
|
@ -141,9 +143,13 @@ func (m *Media) Start(id int64) error {
|
|||
|
||||
workDir := filepath.Join(m.DataDir, "work", st.Name)
|
||||
wwwDir := filepath.Join(m.DataDir, "www", st.Name)
|
||||
variantSpecs := db.ParseVariantsJSON(st.VariantsJSON)
|
||||
// Fresh dirs each start — leftover decrypted segments make NRE File.Move fail.
|
||||
_ = os.RemoveAll(wwwDir)
|
||||
_ = os.RemoveAll(workDir)
|
||||
for _, v := range db.ScaledVariants(variantSpecs) {
|
||||
_ = os.RemoveAll(filepath.Join(m.DataDir, "www", st.Name+"-"+v.ID))
|
||||
}
|
||||
for _, d := range []string{workDir, wwwDir, filepath.Join(m.DataDir, "logs")} {
|
||||
if err := os.MkdirAll(d, 0o755); err != nil {
|
||||
return err
|
||||
|
|
@ -289,6 +295,7 @@ func (m *Media) Start(id int64) error {
|
|||
nreLog: nreLog,
|
||||
mpdProxy: mpdProxy,
|
||||
|
||||
variantSpecs: variantSpecs,
|
||||
tsReadyBytes: cfg.TSReadyBytes,
|
||||
}
|
||||
|
||||
|
|
@ -358,6 +365,7 @@ func (m *Media) bootstrapHLS(sp *streamProc) {
|
|||
})
|
||||
return
|
||||
}
|
||||
m.startVariantPackagers(sp, sp.variantSpecs)
|
||||
pid := int64(0)
|
||||
if sp.nre != nil && sp.nre.Process != nil {
|
||||
pid = int64(sp.nre.Process.Pid)
|
||||
|
|
@ -458,6 +466,7 @@ func (m *Media) Stop(id int64) error {
|
|||
_ = m.Store.SetRuntime(id, db.RuntimePatch{Health: "stopped", PlayPath: "/hls/" + name + "/index.m3u8"})
|
||||
return nil
|
||||
}
|
||||
m.stopAllVariants(sp)
|
||||
nrePID, ffPID := 0, 0
|
||||
if sp.ffmpeg != nil && sp.ffmpeg.Process != nil {
|
||||
ffPID = sp.ffmpeg.Process.Pid
|
||||
|
|
@ -584,6 +593,7 @@ func (m *Media) refreshHealth(id int64) {
|
|||
if ffDead && health != "down" {
|
||||
go m.restartFFmpeg(sp)
|
||||
}
|
||||
go m.restartDeadVariants(sp)
|
||||
}
|
||||
|
||||
func (m *Media) restartFFmpeg(sp *streamProc) {
|
||||
|
|
@ -618,7 +628,15 @@ func (m *Media) restartFFmpeg(sp *streamProc) {
|
|||
cur.ffDead = true
|
||||
}
|
||||
m.mu.Unlock()
|
||||
return
|
||||
}
|
||||
m.mu.Lock()
|
||||
specs := sp.variantSpecs
|
||||
if cur, ok := m.procs[sp.id]; ok {
|
||||
specs = cur.variantSpecs
|
||||
}
|
||||
m.mu.Unlock()
|
||||
m.startVariantPackagers(sp, specs)
|
||||
}
|
||||
|
||||
func (m *Media) logf(format string, args ...any) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue