Browse Source

hls: stop spamming 'stream doesn't contain any supported codec' when hlsAlwaysRemux is true (#3018)

pull/3019/head
Alessandro Ros 1 year ago committed by GitHub
parent
commit
ba69241377
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 2
      internal/servers/hls/muxer.go
  2. 7
      internal/servers/hls/muxer_instance.go
  3. 6
      internal/servers/rtmp/conn.go
  4. 6
      internal/servers/webrtc/session.go

2
internal/servers/hls/muxer.go

@ -153,7 +153,7 @@ func (m *muxer) runInner() error {
} }
err = mi.initialize() err = mi.initialize()
if err != nil { if err != nil {
if m.remoteAddr != "" { if m.remoteAddr != "" || errors.Is(err, errNoSupportedCodecs) {
return err return err
} }

7
internal/servers/hls/muxer_instance.go

@ -1,6 +1,7 @@
package hls package hls
import ( import (
"errors"
"fmt" "fmt"
"os" "os"
"path/filepath" "path/filepath"
@ -18,6 +19,9 @@ import (
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
) )
var errNoSupportedCodecs = errors.New(
"the stream doesn't contain any supported codec, which are currently H265, H264, Opus, MPEG-4 Audio")
type muxerInstance struct { type muxerInstance struct {
variant conf.HLSVariant variant conf.HLSVariant
segmentCount int segmentCount int
@ -43,8 +47,7 @@ func (mi *muxerInstance) initialize() error {
if videoTrack == nil && audioTrack == nil { if videoTrack == nil && audioTrack == nil {
mi.stream.RemoveReader(mi.writer) mi.stream.RemoveReader(mi.writer)
return fmt.Errorf( return errNoSupportedCodecs
"the stream doesn't contain any supported codec, which are currently H265, H264, Opus, MPEG-4 Audio")
} }
var muxerDirectory string var muxerDirectory string

6
internal/servers/rtmp/conn.go

@ -32,6 +32,9 @@ const (
pauseAfterAuthError = 2 * time.Second pauseAfterAuthError = 2 * time.Second
) )
var errNoSupportedCodecs = errors.New(
"the stream doesn't contain any supported codec, which are currently H264, MPEG-4 Audio, MPEG-1/2 Audio")
func pathNameAndQuery(inURL *url.URL) (string, url.Values, string) { func pathNameAndQuery(inURL *url.URL) (string, url.Values, string) {
// remove leading and trailing slashes inserted by OBS and some other clients // remove leading and trailing slashes inserted by OBS and some other clients
tmp := strings.TrimRight(inURL.String(), "/") tmp := strings.TrimRight(inURL.String(), "/")
@ -212,8 +215,7 @@ func (c *conn) runRead(conn *rtmp.Conn, u *url.URL) error {
writer) writer)
if videoFormat == nil && audioFormat == nil { if videoFormat == nil && audioFormat == nil {
return fmt.Errorf( return errNoSupportedCodecs
"the stream doesn't contain any supported codec, which are currently H264, MPEG-4 Audio, MPEG-1/2 Audio")
} }
c.Log(logger.Info, "is reading from path '%s', %s", c.Log(logger.Info, "is reading from path '%s', %s",

6
internal/servers/webrtc/session.go

@ -32,6 +32,9 @@ import (
"github.com/bluenviron/mediamtx/internal/unit" "github.com/bluenviron/mediamtx/internal/unit"
) )
var errNoSupportedCodecs = errors.New(
"the stream doesn't contain any supported codec, which are currently AV1, VP9, VP8, H264, Opus, G722, G711")
type setupStreamFunc func(*webrtc.OutgoingTrack) error type setupStreamFunc func(*webrtc.OutgoingTrack) error
func findVideoTrack( func findVideoTrack(
@ -547,8 +550,7 @@ func (s *session) runRead() (int, error) {
audioTrack, audioSetup := findAudioTrack(stream, writer) audioTrack, audioSetup := findAudioTrack(stream, writer)
if videoTrack == nil && audioTrack == nil { if videoTrack == nil && audioTrack == nil {
return http.StatusBadRequest, fmt.Errorf( return http.StatusBadRequest, errNoSupportedCodecs
"the stream doesn't contain any supported codec, which are currently AV1, VP9, VP8, H264, Opus, G722, G711")
} }
tracks, err := pc.SetupOutgoingTracks(videoTrack, audioTrack) tracks, err := pc.SetupOutgoingTracks(videoTrack, audioTrack)

Loading…
Cancel
Save