Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CallbackEncoder ¶ added in v0.2.0
type CallbackEncoder interface { Encoder // Options は、このエンコーダに指定されたオプションを返します。 Options() EncoderOptions // Frame は、現在エンコード中のフレーム番号を返します。 Frame() int // SetY は、Yチャンネルの位置 (x, y) における画素値を設定します。 SetY(x, y int, value uint8) // SetU は、Uチャンネルの位置 (x*2, y*2) - (x*2+1, y*2+1) における画素値を設定します。 SetU(xHalf, yHalf int, value uint8) // SetV は、Vチャンネルの位置 (x*2, y*2) - (x*2+1, y*2+1) における画素値を設定します。 SetV(xHalf, yHalf int, value uint8) }
CallbackEncoder は、コールバック中で画素を描画するビデオエンコーダです。
Example ¶
filename := "example-callback-encoder.mp4" os.Remove(filename) opts := simplevid.EncoderOptions{ Width: 1280, Height: 720, BitRate: 4 * 1024 * 1024, GOPSize: 10, FPS: 30, } e := simplevid.NewCallbackEncoder(opts, func(e simplevid.CallbackEncoder) bool { frame := e.Frame() if frame == 30 { return false } opts := e.Options() for y := 0; y < opts.Height; y++ { for x := 0; x < opts.Width; x++ { e.SetY(x, y, uint8(x+y+frame*3)) } } for y := 0; y < opts.Height/2; y++ { for x := 0; x < opts.Width/2; x++ { e.SetU(x, y, uint8(128+y+frame*2)) e.SetV(x, y, uint8(64+x+frame*5)) } } return true }) if err := e.EncodeToFile(filename); err != nil { panic(err) } if _, err := os.Stat(filename); err != nil { panic(err) } fmt.Printf("%s is created.\n", filename)
Output: example-callback-encoder.mp4 is created.
func NewCallbackEncoder ¶ added in v0.2.0
func NewCallbackEncoder(opts EncoderOptions, onDraw func(CallbackEncoder) bool) CallbackEncoder
NewCallbackEncoder は、新しい CallbackEncoder を返します。
type Encoder ¶
type Encoder interface { // EncodeToFile は、ビデオをエンコードしてファイルに保存します。 EncodeToFile(filename string) error }
Encoder は、ビデオエンコーダです。
func NewImageEncoder ¶ added in v0.2.0
func NewImageEncoder(opts EncoderOptions, ch <-chan image.Image) Encoder
NewImageEncoder は、フレーム画像をチャネル経由で Image として渡す方式の新しい Encoder を返します。
type EncoderOptions ¶
type EncoderOptions struct { // Width は、ビデオ画面の横幅 [px] です。 Width int // Height は、ビデオ画面の縦幅 [px] です。 Height int // BitRate は、ビットレート [byte/sec] です。 BitRate int // GOPSize は、GOP (Group Of Picture) フレーム数です。 GOPSize int // FPS は、1秒あたりのフレーム数です。 FPS int }
EncoderOptions は、ビデオエンコーダのオプションです。
Click to show internal directories.
Click to hide internal directories.