Skip to content

Commit c490419

Browse files
committed
fix #25: prevent avfoundation printing to stderr
this is a hack at best. ideally ffmpeg avfoundation would respect -loglevel
1 parent 3456e23 commit c490419

File tree

2 files changed

+15
-2
lines changed

2 files changed

+15
-2
lines changed

input/common/execread/execread.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ type Session struct {
2020
// OnStart is called when the session starts. Nil by default.
2121
OnStart func(ctx context.Context, cmd *exec.Cmd) error
2222

23+
// prevents cmd.Stderr from poiting to os.Stderr. false by default.
24+
// this is a hack for github noriah/catnip#25
25+
DisconnectedStderr bool
26+
2327
argv []string
2428
cfg input.SessionConfig
2529

@@ -49,7 +53,10 @@ func (s *Session) Start(ctx context.Context, dst [][]input.Sample, kickChan chan
4953
}
5054

5155
cmd := exec.CommandContext(ctx, s.argv[0], s.argv[1:]...)
52-
cmd.Stderr = os.Stderr
56+
57+
if !s.DisconnectedStderr {
58+
cmd.Stderr = os.Stderr
59+
}
5360

5461
o, err := cmd.StdoutPipe()
5562
if err != nil {

input/ffmpeg/avfoundation.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ func (p AVFoundation) Start(cfg input.SessionConfig) (input.Session, error) {
115115
return nil, fmt.Errorf("invalid device type %T", cfg.Device)
116116
}
117117

118-
return NewSession(dv, cfg)
118+
session, err := NewSession(dv, cfg)
119+
120+
// HACK(github noriah/catnip#25) ffmpeg avfoundation (darwin) unconditionally
121+
// prints errors even with loglevel set to panic or quiet.
122+
session.DisconnectedStderr = true
123+
124+
return session, err
119125
}
120126

121127
type AVFoundationDevice struct {

0 commit comments

Comments
 (0)