Skip to content

Commit

Permalink
Merge pull request #1450 from edenhaus/ffmpeg-codec-not-matched-error
Browse files Browse the repository at this point in the history
Lower codec not matched error for ffmpeg to debug
  • Loading branch information
AlexxIT authored Nov 11, 2024
2 parents 80ac0ab + 570b7d0 commit 715be4d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 3 additions & 0 deletions internal/ffmpeg/ffmpeg.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,9 @@ func parseArgs(s string) *ffmpeg.Args {
s += "?video&audio"
}
s += "&source=ffmpeg:" + url.QueryEscape(source)
for _, v := range query["query"] {
s += "&" + v
}
args.Input = inputTemplate("rtsp", s, query)
} else if i = strings.Index(s, "?"); i > 0 {
switch s[:i] {
Expand Down
12 changes: 10 additions & 2 deletions internal/rtsp/rtsp.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ func tcpHandler(conn *rtsp.Conn) {
var closer func()

trace := log.Trace().Enabled()
level := zerolog.WarnLevel

conn.Listen(func(msg any) {
if trace {
Expand Down Expand Up @@ -188,11 +189,18 @@ func tcpHandler(conn *rtsp.Conn) {
conn.PacketSize = uint16(core.Atoi(s))
}

// param name like ffmpeg style https://ffmpeg.org/ffmpeg-protocols.html
if s := query.Get("log_level"); s != "" {
if lvl, err := zerolog.ParseLevel(s); err == nil {
level = lvl
}
}

// will help to protect looping requests to same source
conn.Connection.Source = query.Get("source")

if err := stream.AddConsumer(conn); err != nil {
log.Warn().Err(err).Str("stream", name).Msg("[rtsp]")
log.WithLevel(level).Err(err).Str("stream", name).Msg("[rtsp]")
return
}

Expand Down Expand Up @@ -230,7 +238,7 @@ func tcpHandler(conn *rtsp.Conn) {

if err := conn.Accept(); err != nil {
if err != io.EOF {
log.Warn().Err(err).Caller().Send()
log.WithLevel(level).Err(err).Caller().Send()
}
if closer != nil {
closer()
Expand Down

0 comments on commit 715be4d

Please sign in to comment.