52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package stream
|
|
|
|
import (
|
|
"io"
|
|
|
|
"git.kingecg.top/kingecg/goffmpeg/pkg/ffmpeg"
|
|
)
|
|
|
|
// TranscodeOptions defines options for stream transcode/transform
|
|
type TranscodeOptions struct {
|
|
// Input options
|
|
InputURL string // rtsp://, http://, https://, ws://, or file path
|
|
InputIO io.Reader // If set, InputURL is ignored (data piped to FFmpeg)
|
|
|
|
// Output options
|
|
OutputFormat string // Output container format: "mp4", "flv", "mkv", "raw"
|
|
VideoCodec string // Video codec: "libx264", "libvpx", "copy", empty = no video
|
|
AudioCodec string // Audio codec: "aac", "mp3", "copy", empty = no audio
|
|
|
|
// Video options
|
|
VideoWidth int
|
|
VideoHeight int
|
|
VideoBitRate int64
|
|
FrameRate ffmpeg.Rational
|
|
PixelFormat string
|
|
VideoFilter string // FFmpeg video filter string
|
|
|
|
// Audio options
|
|
AudioBitRate int64
|
|
AudioSampleRate int
|
|
AudioChannels int
|
|
AudioFilter string // FFmpeg audio filter string
|
|
|
|
// General options
|
|
BufferSize int // Internal buffer size (default 4096)
|
|
}
|
|
|
|
// Validate validates the options
|
|
func (o *TranscodeOptions) Validate() error {
|
|
// At least one input required
|
|
if o.InputURL == "" && o.InputIO == nil {
|
|
return ErrNoInput
|
|
}
|
|
|
|
// Buffer size default
|
|
if o.BufferSize <= 0 {
|
|
o.BufferSize = 4096
|
|
}
|
|
|
|
return nil
|
|
}
|