Added Classer + now logs returns a Classer + tests are now done in astiav package

This commit is contained in:
Quentin Renard
2024-02-28 18:05:36 +01:00
parent 7fe358fbfa
commit b5db8fb22f
51 changed files with 1177 additions and 808 deletions

View File

@@ -42,8 +42,14 @@ type stream struct {
func main() {
// Handle ffmpeg logs
astiav.SetLogLevel(astiav.LogLevelDebug)
astiav.SetLogCallback(func(l astiav.LogLevel, fmt, msg, parent string) {
log.Printf("ffmpeg log: %s (level: %d)\n", strings.TrimSpace(msg), l)
astiav.SetLogCallback(func(c astiav.Classer, l astiav.LogLevel, fmt, msg string) {
var cs string
if c != nil {
if cl := c.Class(); cl != nil {
cs = " - class: " + cl.String()
}
}
log.Printf("ffmpeg log: %s%s - level: %d\n", strings.TrimSpace(msg), cs, l)
})
// Parse flags
@@ -306,11 +312,9 @@ func openOutputFile() (err error) {
// If this is a file, we need to use an io context
if !outputFormatContext.OutputFormat().Flags().Has(astiav.IOFormatFlagNofile) {
// Create io context
ioContext := astiav.NewIOContext()
// Open io context
if err = ioContext.Open(*output, astiav.NewIOContextFlags(astiav.IOContextFlagWrite)); err != nil {
var ioContext *astiav.IOContext
if ioContext, err = astiav.OpenIOContext(*output, astiav.NewIOContextFlags(astiav.IOContextFlagWrite)); err != nil {
err = fmt.Errorf("main: opening io context failed: %w", err)
return
}