Skip to content

Commit

Permalink
Merge pull request #109 from allenporter/hls-crash
Browse files Browse the repository at this point in the history
Crash fix: don't write packets for uninitialized HLS segments
  • Loading branch information
allenporter authored Feb 21, 2022
2 parents ea35fae + 0a68117 commit b343e97
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions hlsMuxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ func (element *MuxerHLS) WritePacket(packet *av.Packet) {
element.mutex.Lock()
defer element.mutex.Unlock()
//TODO delete packet.IsKeyFrame if need no EXT-X-INDEPENDENT-SEGMENTS

if !packet.IsKeyFrame && element.CurrentSegment == nil {
// Wait for the first keyframe before initializing
return
}
if packet.IsKeyFrame && (element.CurrentSegment == nil || element.CurrentSegment.GetDuration().Seconds() >= 4) {
if element.CurrentSegment != nil {
element.CurrentSegment.Close()
Expand Down

0 comments on commit b343e97

Please sign in to comment.