Fix last segment never showing on transcode/transmux

This commit is contained in:
Zoe Roux 2024-02-17 16:08:52 +01:00
parent 2b59a35bf3
commit 050b420f9a

View File

@ -314,6 +314,10 @@ func (ts *Stream) GetIndex() (string, error) {
index += fmt.Sprintf("#EXTINF:%.6f\n", ts.file.Keyframes[segment+1]-ts.file.Keyframes[segment])
index += fmt.Sprintf("segment-%d.ts\n", segment)
}
// do not forget to add the last segment between the last keyframe and the end of the file
index += fmt.Sprintf("#EXTINF:%.6f\n", float64(ts.file.Info.Duration)-ts.file.Keyframes[len(ts.file.Keyframes)-1])
index += fmt.Sprintf("segment-%d.ts\n", len(ts.file.Keyframes)-1)
index += `#EXT-X-ENDLIST`
return index, nil
}