Fix FLAC mime type for Chrome
This commit is contained in:
+8
-4
@@ -1,6 +1,11 @@
|
|||||||
package hls
|
package hls
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"net/http"
|
||||||
|
"strings"
|
||||||
|
"sync"
|
||||||
|
"time"
|
||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/internal/api"
|
"github.com/AlexxIT/go2rtc/internal/api"
|
||||||
"github.com/AlexxIT/go2rtc/internal/api/ws"
|
"github.com/AlexxIT/go2rtc/internal/api/ws"
|
||||||
"github.com/AlexxIT/go2rtc/internal/app"
|
"github.com/AlexxIT/go2rtc/internal/app"
|
||||||
@@ -10,9 +15,6 @@ import (
|
|||||||
"github.com/AlexxIT/go2rtc/pkg/mpegts"
|
"github.com/AlexxIT/go2rtc/pkg/mpegts"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
"github.com/AlexxIT/go2rtc/pkg/tcp"
|
||||||
"github.com/rs/zerolog"
|
"github.com/rs/zerolog"
|
||||||
"net/http"
|
|
||||||
"sync"
|
|
||||||
"time"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Init() {
|
func Init() {
|
||||||
@@ -137,9 +139,11 @@ segment.ts?id=` + sid + `&n=%d`
|
|||||||
sessions[sid] = session
|
sessions[sid] = session
|
||||||
sessionsMu.Unlock()
|
sessionsMu.Unlock()
|
||||||
|
|
||||||
|
codecs := strings.Replace(cons.MimeCodecs(), mp4.MimeFlac, "fLaC", 1)
|
||||||
|
|
||||||
// bandwidth important for Safari, codecs useful for smooth playback
|
// bandwidth important for Safari, codecs useful for smooth playback
|
||||||
data := []byte(`#EXTM3U
|
data := []byte(`#EXTM3U
|
||||||
#EXT-X-STREAM-INF:BANDWIDTH=192000,CODECS="` + cons.MimeCodecs() + `"
|
#EXT-X-STREAM-INF:BANDWIDTH=192000,CODECS="` + codecs + `"
|
||||||
hls/playlist.m3u8?id=` + sid)
|
hls/playlist.m3u8?id=` + sid)
|
||||||
|
|
||||||
if _, err := w.Write(data); err != nil {
|
if _, err := w.Write(data); err != nil {
|
||||||
|
|||||||
+4
-1
@@ -2,6 +2,7 @@ package hls
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/internal/api"
|
"github.com/AlexxIT/go2rtc/internal/api"
|
||||||
@@ -68,9 +69,11 @@ segment.m4s?id=` + sid + `&n=%d`
|
|||||||
sessions[sid] = session
|
sessions[sid] = session
|
||||||
sessionsMu.Unlock()
|
sessionsMu.Unlock()
|
||||||
|
|
||||||
|
codecs = strings.Replace(cons.MimeCodecs(), mp4.MimeFlac, "fLaC", 1)
|
||||||
|
|
||||||
// bandwidth important for Safari, codecs useful for smooth playback
|
// bandwidth important for Safari, codecs useful for smooth playback
|
||||||
data := `#EXTM3U
|
data := `#EXTM3U
|
||||||
#EXT-X-STREAM-INF:BANDWIDTH=192000,CODECS="` + cons.MimeCodecs() + `"
|
#EXT-X-STREAM-INF:BANDWIDTH=192000,CODECS="` + codecs + `"
|
||||||
hls/playlist.m3u8?id=` + sid
|
hls/playlist.m3u8?id=` + sid
|
||||||
|
|
||||||
tr.Write(&ws.Message{Type: "hls", Value: data})
|
tr.Write(&ws.Message{Type: "hls", Value: data})
|
||||||
|
|||||||
+3
-2
@@ -2,6 +2,7 @@ package mp4
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
|
|
||||||
"github.com/AlexxIT/go2rtc/pkg/core"
|
"github.com/AlexxIT/go2rtc/pkg/core"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/h264"
|
"github.com/AlexxIT/go2rtc/pkg/h264"
|
||||||
"github.com/AlexxIT/go2rtc/pkg/h265"
|
"github.com/AlexxIT/go2rtc/pkg/h265"
|
||||||
@@ -22,7 +23,7 @@ const (
|
|||||||
MimeH264 = "avc1.640029"
|
MimeH264 = "avc1.640029"
|
||||||
MimeH265 = "hvc1.1.6.L153.B0"
|
MimeH265 = "hvc1.1.6.L153.B0"
|
||||||
MimeAAC = "mp4a.40.2"
|
MimeAAC = "mp4a.40.2"
|
||||||
MimeFlac = "fLaC" // case is important for Apple HLS
|
MimeFlac = "flac"
|
||||||
MimeOpus = "opus"
|
MimeOpus = "opus"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -64,7 +65,7 @@ func (m *Muxer) GetInit(codecs []*core.Codec) ([]byte, error) {
|
|||||||
switch codec.Name {
|
switch codec.Name {
|
||||||
case core.CodecH264:
|
case core.CodecH264:
|
||||||
sps, pps := h264.GetParameterSet(codec.FmtpLine)
|
sps, pps := h264.GetParameterSet(codec.FmtpLine)
|
||||||
// some dummy SPS and PPS not a problem
|
// some dummy SPS and PPS not a problem for MP4, but problem for HLS :(
|
||||||
if len(sps) == 0 {
|
if len(sps) == 0 {
|
||||||
sps = []byte{0x67, 0x42, 0x00, 0x0a, 0xf8, 0x41, 0xa2}
|
sps = []byte{0x67, 0x42, 0x00, 0x0a, 0xf8, 0x41, 0xa2}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user