wip: Try to fix disconituity segment

This commit is contained in:
Zoe Roux 2024-07-15 00:22:13 +07:00
parent 2ae26d108d
commit f03464aa4c
No known key found for this signature in database
3 changed files with 13 additions and 2 deletions

View File

@ -68,7 +68,10 @@ func (fs *FileStream) Destroy() {
} }
func (fs *FileStream) GetMaster() string { func (fs *FileStream) GetMaster() string {
master := "#EXTM3U\n" master := `#EXTM3U
#EXT-X-VERSION:7
#EXT-X-INDEPENDENT-SEGMENTS
`
if fs.Info.Video != nil { if fs.Info.Video != nil {
var transmux_quality Quality var transmux_quality Quality
for _, quality := range Qualities { for _, quality := range Qualities {

View File

@ -17,7 +17,6 @@ const OptimalFragmentDuration = float64(5)
type Keyframe struct { type Keyframe struct {
Sha string Sha string
Keyframes []float64 Keyframes []float64
CanTransmux bool
IsDone bool IsDone bool
info *KeyframeInfo info *KeyframeInfo
} }

View File

@ -271,6 +271,15 @@ func (ts *Stream) run(start int32) error {
"-muxdelay", "0", "-muxdelay", "0",
) )
args = append(args, ts.handle.getTranscodeArgs(toSegmentStr(segments))...) args = append(args, ts.handle.getTranscodeArgs(toSegmentStr(segments))...)
if start_ref != 0 {
args = append(args,
// We need to add frag_discout to the movflags to get ffmpeg to calculate the correct presentation time otherwise players get lost.
// Since we can't append to movflags but only override them, we also copy the default hls w/ fmp4 movflags
// Initial flags from: https://github.com/FFmpeg/FFmpeg/blob/master/libavformat/hlsenc.c#L934C32-L934C72
"-hls_segment_options", "movflags=frag_custom+dash+delay_moov+frag_discont",
)
}
args = append(args, args = append(args,
"-f", "hls", "-f", "hls",
"-hls_time", fmt.Sprint(OptimalFragmentDuration), "-hls_time", fmt.Sprint(OptimalFragmentDuration),