diff --git a/transcoder/src/filestream.go b/transcoder/src/filestream.go index fb924373..d5b134bf 100644 --- a/transcoder/src/filestream.go +++ b/transcoder/src/filestream.go @@ -68,7 +68,10 @@ func (fs *FileStream) Destroy() { } func (fs *FileStream) GetMaster() string { - master := "#EXTM3U\n" + master := `#EXTM3U +#EXT-X-VERSION:7 +#EXT-X-INDEPENDENT-SEGMENTS +` if fs.Info.Video != nil { var transmux_quality Quality for _, quality := range Qualities { diff --git a/transcoder/src/keyframes.go b/transcoder/src/keyframes.go index ab902c55..5bdc8aaf 100644 --- a/transcoder/src/keyframes.go +++ b/transcoder/src/keyframes.go @@ -17,7 +17,6 @@ const OptimalFragmentDuration = float64(5) type Keyframe struct { Sha string Keyframes []float64 - CanTransmux bool IsDone bool info *KeyframeInfo } diff --git a/transcoder/src/stream.go b/transcoder/src/stream.go index 850bcc17..cc112d18 100644 --- a/transcoder/src/stream.go +++ b/transcoder/src/stream.go @@ -271,6 +271,15 @@ func (ts *Stream) run(start int32) error { "-muxdelay", "0", ) 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, "-f", "hls", "-hls_time", fmt.Sprint(OptimalFragmentDuration),