-
Notifications
You must be signed in to change notification settings - Fork 0
/
frames.go
37 lines (31 loc) · 858 Bytes
/
frames.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package io
import (
"fmt"
"github.com/peter-mount/go-anim/util/time"
"os"
)
// FrameSession handles sending frames to individual images on disk
type FrameSession struct {
RenderStreamBase
}
func (_ Render) frames(fileName string, frameRate int, encoder Encoder) *FrameSession {
s := &FrameSession{
RenderStreamBase: RenderStreamBase{
fileName: fileName,
timeCode: time.NewTimeCode(frameRate),
encoder: encoder,
},
}
s.RenderStreamBase.write = s.writeBytes
return s
}
func (s *FrameSession) writeBytes(b []byte) (int, error) {
fileName := fmt.Sprintf(s.fileName, s.TimeCode().FrameNum())
return 0, os.WriteFile(fileName, b, 0644)
}
// Close closes the FrameSession.
// Normally this is handled by try-resources
func (s *FrameSession) Close() error {
// For now does nothing, just to implement the Writer interface
return nil
}