Fixing dropping frames

This commit is contained in:
YamiOdymel 2020-02-13 15:15:40 +08:00
parent 08d2455d5c
commit 2911eb217e
No known key found for this signature in database
GPG Key ID: 68E469836934DB36

23
main.go
View File

@ -214,11 +214,18 @@ func fetchSegment(master *os.File, segment *m3u8.MediaSegment, baseURL string, f
break
}
//
b, _ := ioutil.ReadFile(fmt.Sprintf("%s~%d.ts", filename, index-1))
if _, err := master.Write(b); err != nil {
panic(err)
if retry > 3 {
//
b, _ := ioutil.ReadFile(fmt.Sprintf("%s~%d.ts", filename, index))
master.Write(b)
//
os.Remove(fmt.Sprintf("%s~%d.ts", filename, index))
return
}
//
b, _ := ioutil.ReadFile(fmt.Sprintf("%s~%d.ts", filename, index-1))
master.Write(b)
//
os.Remove(fmt.Sprintf("%s~%d.ts", filename, index-1))
}
@ -237,8 +244,8 @@ func endpoint(c *cli.Context) error {
continue
}
// Otherwise we keep checking the channel status until the user is online.
log.Printf("%s is offlined, check again after 1 minutes...", c.String("username"))
<-time.After(time.Minute * 1)
log.Printf("%s is offlined, check again after %d minutes...", c.String("username"), c.Int("interval"))
<-time.After(time.Minute * time.Duration(c.Int("interval")))
}
return nil
}
@ -258,6 +265,12 @@ func main() {
Value: "",
Usage: "video quality with `high`, `medium` and `low`",
},
&cli.IntFlag{
Name: "interval",
Aliases: []string{"i"},
Value: 1,
Usage: "minutes to check if a channel goes online or not",
},
},
Name: "chaturbate-dvr",
Usage: "watching a specified chaturbate channel and auto saved to local file",