Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Feb 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion internal/servers/hls/muxer.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@
}
err = mi.initialize()
if err != nil {
if m.remoteAddr != "" {
if m.remoteAddr != "" || errors.Is(err, errNoSupportedCodecs) {

Check warning on line 156 in internal/servers/hls/muxer.go

View check run for this annotation

Codecov / codecov/patch

internal/servers/hls/muxer.go#L156

Added line #L156 was not covered by tests
return err
}

Expand Down
7 changes: 5 additions & 2 deletions internal/servers/hls/muxer_instance.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package hls

import (
"errors"
"fmt"
"os"
"path/filepath"
Expand All @@ -18,6 +19,9 @@
"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 {
variant conf.HLSVariant
segmentCount int
Expand All @@ -43,8 +47,7 @@

if videoTrack == nil && audioTrack == nil {
mi.stream.RemoveReader(mi.writer)
return fmt.Errorf(
"the stream doesn't contain any supported codec, which are currently H265, H264, Opus, MPEG-4 Audio")
return errNoSupportedCodecs

Check warning on line 50 in internal/servers/hls/muxer_instance.go

View check run for this annotation

Codecov / codecov/patch

internal/servers/hls/muxer_instance.go#L50

Added line #L50 was not covered by tests
}

var muxerDirectory string
Expand Down
6 changes: 4 additions & 2 deletions internal/servers/rtmp/conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ const (
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) {
// remove leading and trailing slashes inserted by OBS and some other clients
tmp := strings.TrimRight(inURL.String(), "/")
Expand Down Expand Up @@ -212,8 +215,7 @@ func (c *conn) runRead(conn *rtmp.Conn, u *url.URL) error {
writer)

if videoFormat == nil && audioFormat == nil {
return fmt.Errorf(
"the stream doesn't contain any supported codec, which are currently H264, MPEG-4 Audio, MPEG-1/2 Audio")
return errNoSupportedCodecs
}

c.Log(logger.Info, "is reading from path '%s', %s",
Expand Down
6 changes: 4 additions & 2 deletions internal/servers/webrtc/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ import (
"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

func findVideoTrack(
Expand Down Expand Up @@ -547,8 +550,7 @@ func (s *session) runRead() (int, error) {
audioTrack, audioSetup := findAudioTrack(stream, writer)

if videoTrack == nil && audioTrack == nil {
return http.StatusBadRequest, fmt.Errorf(
"the stream doesn't contain any supported codec, which are currently AV1, VP9, VP8, H264, Opus, G722, G711")
return http.StatusBadRequest, errNoSupportedCodecs
}

tracks, err := pc.SetupOutgoingTracks(videoTrack, audioTrack)
Expand Down
Loading