vnc-recorder icon indicating copy to clipboard operation
vnc-recorder copied to clipboard

End of record

Open michabbs opened this issue 4 years ago • 1 comments

Maybe it's stupid question, but... how to end the recording? Is Ctrl+C the only option? You could add something like --timeout option to pre-set the recoding time.

michabbs avatar Nov 11 '20 21:11 michabbs

You can write it by yourself. It's simply

Adding cli.StringFlag while initialize

			&cli.StringFlag{
				Name:    "timeout",
				Value:   0,
				Usage:   "Record time in seconds. By default 0 (infitiny)",
				EnvVars: []string{"VR_TIMEOUT"},
			},

Make some channel: timeoutCh := make(chan bool, 1) And realize simply counter which be use something like that

if c.timeout > 0 {
  timeLeft := time.Now().Local().Add(time.Second * time.Duration(c.timeout)
  if timeNow() > timeLeft {
    timeoutCh <- true
  }
}

And in final add in main loop listenner:

case timeout := <-timeoutCh:
			if timeout != nil {
				log.Println("Record timeout reached")
				vcodec.Close()
				// give some time to write the file
				time.Sleep(time.Second * 1)
				os.Exit(0)
			}

solyard avatar Nov 26 '20 10:11 solyard