Documentation
¶
Index ¶
- Variables
- type EncodeOptions
- type EncodeSession
- func (e *EncodeSession) Cleanup()
- func (e *EncodeSession) FrameDuration() time.Duration
- func (e *EncodeSession) OpusFrame() (frame []byte, err error)
- func (e *EncodeSession) Read(p []byte) (n int, err error)
- func (e *EncodeSession) ReadFrame() (frame []byte, err error)
- func (e *EncodeSession) Running() (running bool)
- func (e *EncodeSession) Stop() error
- func (e *EncodeSession) Truncate()
- type Frame
- type OpusReader
- type StreamingSession
Constants ¶
This section is empty.
Variables ¶
var (
ErrBadFrame = errors.New("bad frame")
)
var (
ErrVoiceConnClosed = errors.New("voice connection closed")
)
var StdEncodeOptions = &EncodeOptions{ Volume: 256, FrameRate: 48000, FrameDuration: 20, Bitrate: 64, CompressionLevel: 10, PacketLoss: 1, BufferedFrames: 100, VariableBitrate: true, }
StdEncodeOptions is the standard options for encoding
Functions ¶
This section is empty.
Types ¶
type EncodeOptions ¶
type EncodeOptions struct { Volume int // change audio volume (256=normal) FrameRate int // audio sampling rate (ex 48000) FrameDuration int // audio frame duration can be 20, 40, or 60 (ms) Bitrate int // audio encoding bitrate in kb/s can be 8 - 128 PacketLoss int // expected packet loss percentage CompressionLevel int // Compression level, higher is better quality but slower encoding (0 - 10) BufferedFrames int // How big the frame buffer should be VariableBitrate bool // Whether vbr is used or not (variable bitrate) Threads int // Number of threads to use, 0 for auto }
EncodeOptions is a set of options for encoding dca
type EncodeSession ¶
func EncodeFile ¶
func EncodeFile(path string, options *EncodeOptions) (session *EncodeSession, err error)
EncodeFile encodes the file/url/other in path
func (*EncodeSession) Cleanup ¶
func (e *EncodeSession) Cleanup()
Cleanup cleans up the encoding session, throwing away all unread frames and stopping ffmpeg ensuring that no ffmpeg processes starts piling up on your system You should always call this after it's done
func (*EncodeSession) FrameDuration ¶
func (e *EncodeSession) FrameDuration() time.Duration
FrameDuration implements OpusReader, retruning the duratio of each frame
func (*EncodeSession) OpusFrame ¶
func (e *EncodeSession) OpusFrame() (frame []byte, err error)
OpusFrame implements OpusReader, returning the next opus frame
func (*EncodeSession) Read ¶
func (e *EncodeSession) Read(p []byte) (n int, err error)
Read implements io.Reader, n == len(p) if err == nil, otherwise n contains the number bytes read before an error occured
func (*EncodeSession) ReadFrame ¶
func (e *EncodeSession) ReadFrame() (frame []byte, err error)
ReadFrame blocks until a frame is read or there are no more frames Note: If rawoutput is not set, the first frame will be a metadata frame
func (*EncodeSession) Running ¶
func (e *EncodeSession) Running() (running bool)
Running returns true if running
func (*EncodeSession) Truncate ¶
func (e *EncodeSession) Truncate()
Truncate is deprecated, use Cleanup instead this will be removed in a future version
type OpusReader ¶
type StreamingSession ¶
StreamingSession provides an easy way to directly transmit opus audio to discord from an encode session.
func NewStream ¶
func NewStream(source OpusReader, vc *discordgo.VoiceConnection, done chan error) *StreamingSession
Creates a new stream from an Opusreader. source : The source of the opus frames to be sent, either from an encoder or decoder. vc : The voice connecion to stream to. done : If not nil, an error will be sent on it when completed.
func (*StreamingSession) Finished ¶
func (s *StreamingSession) Finished() (bool, error)
Finished returns whether the stream finished or not, and any error that caused it to stop
func (*StreamingSession) Paused ¶
func (s *StreamingSession) Paused() bool
Paused returns whether the stream is paused or not
func (*StreamingSession) PlaybackPosition ¶
func (s *StreamingSession) PlaybackPosition() time.Duration
PlaybackPosition returns the the duration of content we have transmitted so far
func (*StreamingSession) SetPaused ¶
func (s *StreamingSession) SetPaused(paused bool)
SetPaused provides pause/unpause functionality