vnc-recorder
vnc-recorder copied to clipboard
End of record
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.
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)
}