-
Notifications
You must be signed in to change notification settings - Fork 110
/
video_encoder.go
28 lines (23 loc) · 973 Bytes
/
video_encoder.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
// Package codec defines the encoder and factory interfaces for encoding video frames and audio chunks.
package codec
import (
"context"
"image"
"github.com/edaniels/golog"
)
// DefaultKeyFrameInterval is the default interval chosen
// in order to produce high enough quality results at a low
// latency.
const DefaultKeyFrameInterval = 30
// A VideoEncoder is anything that can encode images into bytes. This means that
// the encoder must follow some type of format dictated by a type (see EncoderFactory.MimeType).
// An encoder that produces bytes of different encoding formats per call is invalid.
type VideoEncoder interface {
Encode(ctx context.Context, img image.Image) ([]byte, error)
Close() error
}
// A VideoEncoderFactory produces VideoEncoders and provides information about the underlying encoder itself.
type VideoEncoderFactory interface {
New(height, width, keyFrameInterval int, logger golog.Logger) (VideoEncoder, error)
MIMEType() string
}