feat(ffmpeg): logging callback handler

This commit is contained in:
Adrian Shum 2022-09-11 11:04:08 +08:00 committed by GitHub
parent f11d2b351c
commit 57541418b9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 71 additions and 1 deletions

View file

@ -29,6 +29,19 @@ func NewProcessor(options ...Option) *Processor {
}
func (p *Processor) Startup(_ context.Context) error {
ffmpeg.SetLogging(func(level ffmpeg.AVLogLevel, message string) {
message = strings.TrimSuffix(message, "\n")
switch level {
case ffmpeg.AVLogTrace, ffmpeg.AVLogDebug, ffmpeg.AVLogVerbose:
p.Logger.Debug("ffmpeg", zap.String("msg", message))
case ffmpeg.AVLogInfo:
p.Logger.Info("ffmpeg", zap.String("msg", message))
case ffmpeg.AVLogWarning:
p.Logger.Warn("ffmpeg", zap.String("msg", message))
case ffmpeg.AVLogError, ffmpeg.AVLogFatal, ffmpeg.AVLogPanic:
p.Logger.Error("ffmpeg", zap.String("msg", message))
}
})
if p.Debug {
ffmpeg.SetFFmpegLogLevel(ffmpeg.AVLogDebug)
} else {