add video encoding. broken for now

This commit is contained in:
Dmitry Fedotov
2025-03-26 00:51:46 +03:00
parent c3b2036713
commit d72540d0c3
5 changed files with 79 additions and 22 deletions

38
video.go Normal file
View File

@@ -0,0 +1,38 @@
package main
import (
"bytes"
"errors"
"io"
vid "github.com/AlexEidt/Vidio"
)
var erreEncodeVideo = errors.New("не удалось создать видео")
func createBarnsLeyFernVideo(s *settings, w io.Writer) error {
opts := &vid.Options{
FPS: 1,
Quality: 0,
Delay: 1000,
}
vw, err := vid.NewVideoWriter(s.Fname, s.X, s.Y, opts)
if err != nil {
return errors.Join(erreEncodeVideo, err)
}
frames := 100
for range frames {
imgbuf := new(bytes.Buffer)
if err := createBarnsleyFernPng(s, imgbuf); err != nil {
return errors.Join(erreEncodeVideo, err)
}
if err := vw.Write(imgbuf.Bytes()); err != nil {
return errors.Join(erreEncodeVideo, err)
}
}
return nil
}