diff --git a/server/broadcast.go b/server/broadcast.go index e95da3af99..7100e0270a 100755 --- a/server/broadcast.go +++ b/server/broadcast.go @@ -840,6 +840,9 @@ func processSegment(ctx context.Context, cxn *rtmpConnection, seg *stream.HLSSeg } clog.V(common.DEBUG).Infof(ctx, "Processing segment dur=%v bytes=%v", seg.Duration, len(seg.Data)) + if segPar != nil && segPar.ForceSessionReinit { + clog.V(common.DEBUG).Infof(ctx, "Requesting HW Session Reinitialization for seg.SeqNo=%v", seg.SeqNo) + } if monitor.Enabled { monitor.SegmentEmerged(ctx, nonce, seg.SeqNo, len(BroadcastJobVideoProfiles), seg.Duration) } diff --git a/server/mediaserver.go b/server/mediaserver.go index af68aca66f..3dca8553ba 100644 --- a/server/mediaserver.go +++ b/server/mediaserver.go @@ -88,6 +88,8 @@ type rtmpConnection struct { lastUsed time.Time sourceBytes uint64 transcodedBytes uint64 + mu sync.Mutex + mediaFormat ffmpeg.MediaFormatInfo } func (s *LivepeerServer) getActiveRtmpConnectionUnsafe(mid core.ManifestID) (*rtmpConnection, bool) { @@ -1012,6 +1014,16 @@ func (s *LivepeerServer) HandlePush(w http.ResponseWriter, r *http.Request) { } }() + // Reinitialize HW Session if video segment resolution has changed + cxn.mu.Lock() + if cxn.mediaFormat == (ffmpeg.MediaFormatInfo{}) { + cxn.mediaFormat = mediaFormat + } else if cxn.mediaFormat != mediaFormat { + cxn.mediaFormat = mediaFormat + segPar.ForceSessionReinit = true + } + cxn.mu.Unlock() + // Do the transcoding! urls, err := processSegment(ctx, cxn, seg, &segPar) if err != nil {