cleaning and preparing for more encoding implementations

This commit is contained in:
amit bezalel 2017-12-30 21:29:35 +02:00
parent 1468ef65b5
commit 41cec2a1e8
5 changed files with 29 additions and 17 deletions

View File

@ -10,9 +10,9 @@ import (
)
type DV8ImageEncoder struct {
cmd *exec.Cmd
cmd *exec.Cmd
binaryPath string
input io.WriteCloser
input io.WriteCloser
}
func (enc *DV8ImageEncoder) Init(videoFileName string) {
@ -25,11 +25,11 @@ func (enc *DV8ImageEncoder) Init(videoFileName string) {
"-f", "image2pipe",
"-vcodec", "ppm",
//"-r", strconv.Itoa(framerate),
"-r", "3",
"-r", "5",
//"-i", "pipe:0",
"-i", "-",
"-vcodec", "libvpx", //"libvpx",//"libvpx-vp9"//"libx264"
"-b:v", "2M",
"-b:v", "1M",
"-threads", "8",
//"-speed", "0",
//"-lossless", "1", //for vpx

View File

@ -10,9 +10,9 @@ import (
)
type DV9ImageEncoder struct {
cmd *exec.Cmd
cmd *exec.Cmd
binaryPath string
input io.WriteCloser
input io.WriteCloser
}
func (enc *DV9ImageEncoder) Init(videoFileName string) {
@ -25,18 +25,18 @@ func (enc *DV9ImageEncoder) Init(videoFileName string) {
"-f", "image2pipe",
"-vcodec", "ppm",
//"-r", strconv.Itoa(framerate),
"-r", "3",
"-r", "5",
//"-i", "pipe:0",
"-i", "-",
"-vcodec", "libvpx-vp9", //"libvpx",//"libvpx-vp9"//"libx264"
"-b:v", "2M",
"-b:v", "1M",
"-threads", "8",
//"-speed", "0",
//"-lossless", "1", //for vpx
// "-tile-columns", "6",
//"-frame-parallel", "1",
// "-an", "-f", "webm",
"-cpu-used", "-16",
"-cpu-used", "-8",
"-preset", "ultrafast",
"-deadline", "realtime",

View File

@ -1,10 +1,12 @@
package vnc2webm
import "encoding/binary"
import "image"
type CursorPseudoEncoding struct {
Colors []Color
BitMask []byte
Image image.Image
}
func (*CursorPseudoEncoding) Supported(Conn) bool {
@ -24,6 +26,7 @@ func (enc *CursorPseudoEncoding) Read(c Conn, rect *Rectangle) error {
if err := binary.Read(c, binary.BigEndian, &bitmask); err != nil {
return err
}
/*
rectStride := 4 * rect.Width
for i := uint16(0); i < rect.Height; i++ {

View File

@ -50,7 +50,10 @@ func main() {
// }
//vcodec := &encoders.MJPegImageEncoder{Quality: 60, Framerate: 6}
vcodec := &encoders.X264ImageEncoder{}
counter := 0
//vcodec := &encoders.DV8ImageEncoder{}
//vcodec := &encoders.DV9ImageEncoder{}
//counter := 0
//vcodec.Init("./output" + strconv.Itoa(counter))
go vcodec.Run("./ffmpeg", "./output.mp4")
@ -85,12 +88,13 @@ func main() {
// fmt.Println(err)
// os.Exit(1)
// }
counter++
//jpeg.Encode(out, screenImage, nil)
vcodec.Encode(screenImage)
reqMsg := vnc.FramebufferUpdateRequest{Inc: 1, X: 0, Y: 0, Width: cc.Width(), Height: cc.Height()}
reqMsg.Write(cc)
if msg.Type() == vnc.FramebufferUpdateMsgType {
//counter++
//jpeg.Encode(out, screenImage, nil)
vcodec.Encode(screenImage)
reqMsg := vnc.FramebufferUpdateRequest{Inc: 1, X: 0, Y: 0, Width: cc.Width(), Height: cc.Height()}
reqMsg.Write(cc)
}
}
}
cc.Wait()

View File

@ -16,7 +16,12 @@ func (c *ServerConn) Config() interface{} {
return c.cfg
}
func (c *ServerConn) GetEncInstance(typ EncodingType) Encoding {
return &TightEncoding{}
for _, enc := range c.encodings {
if enc.Type() == typ {
return enc
}
}
return nil
}
// Conn returns underlining server net.Conn