mirror of https://github.com/stashapp/stash.git
Fix video playback hanging at end (#2996)
Co-authored-by: gerit1a <10052885+gerit1a@users.noreply.github.com>
This commit is contained in:
parent
6b5d5cc628
commit
a6fd577f03
|
@ -206,7 +206,10 @@ func (rs sceneRoutes) streamTranscode(w http.ResponseWriter, r *http.Request, st
|
||||||
lm := manager.GetInstance().ReadLockManager
|
lm := manager.GetInstance().ReadLockManager
|
||||||
streamRequestCtx := manager.NewStreamRequestContext(w, r)
|
streamRequestCtx := manager.NewStreamRequestContext(w, r)
|
||||||
lockCtx := lm.ReadLock(streamRequestCtx, f.Path)
|
lockCtx := lm.ReadLock(streamRequestCtx, f.Path)
|
||||||
defer lockCtx.Cancel()
|
|
||||||
|
// hijacking and closing the connection here causes video playback to hang in Chrome
|
||||||
|
// due to ERR_INCOMPLETE_CHUNKED_ENCODING
|
||||||
|
// We trust that the request context will be closed, so we don't need to call Cancel on the returned context here.
|
||||||
|
|
||||||
stream, err := encoder.GetTranscodeStream(lockCtx, options)
|
stream, err := encoder.GetTranscodeStream(lockCtx, options)
|
||||||
|
|
||||||
|
@ -222,6 +225,7 @@ func (rs sceneRoutes) streamTranscode(w http.ResponseWriter, r *http.Request, st
|
||||||
lockCtx.AttachCommand(stream.Cmd)
|
lockCtx.AttachCommand(stream.Cmd)
|
||||||
|
|
||||||
stream.Serve(w, r)
|
stream.Serve(w, r)
|
||||||
|
w.(http.Flusher).Flush()
|
||||||
}
|
}
|
||||||
|
|
||||||
func (rs sceneRoutes) Screenshot(w http.ResponseWriter, r *http.Request) {
|
func (rs sceneRoutes) Screenshot(w http.ResponseWriter, r *http.Request) {
|
||||||
|
|
|
@ -34,8 +34,21 @@ func (c *StreamRequestContext) Cancel() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// hijack and close the connection
|
// hijack and close the connection
|
||||||
conn, _, _ := hj.Hijack()
|
conn, bw, _ := hj.Hijack()
|
||||||
if conn != nil {
|
if conn != nil {
|
||||||
|
if bw != nil {
|
||||||
|
// notify end of stream
|
||||||
|
_, err := bw.WriteString("0\r\n")
|
||||||
|
if err != nil {
|
||||||
|
logger.Warnf("unable to write end of stream: %v", err)
|
||||||
|
}
|
||||||
|
_, err = bw.WriteString("\r\n")
|
||||||
|
if err != nil {
|
||||||
|
logger.Warnf("unable to write end of stream: %v", err)
|
||||||
|
}
|
||||||
|
_ = bw.Flush()
|
||||||
|
}
|
||||||
|
|
||||||
conn.Close()
|
conn.Close()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue