From cf3d889ba7d64c07ed05e6b2107f6f48a6af09e1 Mon Sep 17 00:00:00 2001 From: Davide Depau Date: Sun, 9 Aug 2020 22:31:12 +0200 Subject: [PATCH] Update vnc2video usage --- main.go | 48 ++++++++++++++++++++++-------------------------- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/main.go b/main.go index 23603e6..63b473d 100644 --- a/main.go +++ b/main.go @@ -94,17 +94,24 @@ func recorder(c *cli.Context) error { cchClient := make(chan vnc.ClientMessage) errorCh := make(chan error) - ccfg := &vnc.ClientConfig{ - SecurityHandlers: []vnc.SecurityHandler{ - // &vnc.ClientAuthATEN{Username: []byte(os.Args[2]), Password: []byte(os.Args[3])} - &vnc.ClientAuthVNC{Password: []byte(c.String("password"))}, + var secHandlers []vnc.SecurityHandler + if c.String("password") == "" { + secHandlers = []vnc.SecurityHandler{ &vnc.ClientAuthNone{}, - }, - DrawCursor: true, - PixelFormat: vnc.PixelFormat32bit, - ClientMessageCh: cchClient, - ServerMessageCh: cchServer, - Messages: vnc.DefaultServerMessages, + } + } else { + secHandlers = []vnc.SecurityHandler{ + &vnc.ClientAuthVNC{Password: []byte(c.String("password"))}, + } + } + + ccfg := &vnc.ClientConfig{ + SecurityHandlers: secHandlers, + DrawCursor: true, + PixelFormat: vnc.PixelFormat32bit, + ClientMessageCh: cchClient, + ServerMessageCh: cchServer, + Messages: vnc.DefaultServerMessages, Encodings: []vnc.Encoding{ &vnc.RawEncoding{}, &vnc.TightEncoding{}, @@ -133,24 +140,13 @@ func recorder(c *cli.Context) error { panic(err) } log.Infof("Using %s for encoding", ffmpeg_path) - vcodec := &encoders.Encoder{ - BinPath: ffmpeg_path, - Framerate: c.Int("framerate"), - Cmd: exec.Command(ffmpeg_path, - "-f", "image2pipe", - "-vcodec", "ppm", - "-r", strconv.Itoa(c.Int("framerate")), - "-an", // no audio - "-y", - "-i", "-", - "-vcodec", "libx264", //"libvpx",//"libvpx-vp9"//"libx264" - "-preset", "fast", - "-crf", "24", - c.String("outfile"), - ), + vcodec := &encoders.X264ImageEncoder{ + FFMpegBinPath: ffmpeg_path, + Framerate: c.Int("framerate"), } - go vcodec.Run() + //goland:noinspection GoUnhandledErrorResult + go vcodec.Run(c.String("outfile")) for _, enc := range ccfg.Encodings { myRenderer, ok := enc.(vnc.Renderer)