func RunFFCM_S(cfg string, dbc dtm.DB_C, h dtm.DTCM_S_H) error { var fcfg = util.NewFcfg3() fcfg.InitWithFilePath2(cfg, true) fcfg.Print() var err = InitDtcmS(fcfg, dbc, h) if err == nil { err = RunFFCM_S_V(fcfg) } return err }
func main() { if len(os.Args) < 2 { usage() ef(1) return } switch os.Args[1] { case "-d": res, err := ffcm.Dim2(os.Args[2:]) if err == nil { fmt.Println(res) } else { fmt.Println(err) ef(1) return } case "-cov": if len(os.Args) < 11 { usage() ef(1) return } err := do_cov(os.Args[2:]) if err != nil { fmt.Println(err) ef(1) return } case "-i": if len(os.Args) < 3 { usage() ef(1) return } var ffprobe = os.Getenv("FFPROBE_C") if len(ffprobe) > 0 { ffcm.FFPROBE_C = ffprobe } video, err := ffcm.ParseVideo(os.Args[2]) if err == nil { fmt.Println(video.Width, " ", video.Height, " ", video.Duration) } else { fmt.Println(err.Error()) ef(1) } case "-c": var cfg = "conf/ffcm_c.properties" if len(os.Args) > 2 { cfg = os.Args[2] } var fcfg_s = util.NewFcfg3() fcfg_s.InitWithFilePath2(cfg, true) fcfg_s.Print() redirect_l(fcfg_s) err := ffcm.RunFFCM_Cv(fcfg_s) fmt.Println(err) smartio.ResetStd() time.Sleep(time.Second) case "-mem": var cfg = "conf/ffcm_s.properties" if len(os.Args) > 2 { cfg = os.Args[2] } var fcfg_s = util.NewFcfg3() fcfg_s.InitWithFilePath2(cfg, true) fcfg_s.Print() redirect_l(fcfg_s) var err = ffcm.InitDtcmS(fcfg_s, dtm.MemDbc, dtm.NewDoNoneH()) if err == nil { err = ffcm.RunFFCM_S_V(fcfg_s) } fmt.Println(err) smartio.ResetStd() time.Sleep(time.Second) case "-verify": if len(os.Args) < 4 { usage() ef(1) return } _, err := ffcm.VerifyVideo(os.Args[2], os.Args[3]) if err == nil { fmt.Println("Verify Success") ef(0) } else { fmt.Println("Verify Fail") fmt.Println(err) ef(1) } return case "-s": var cfg = "conf/ffcm_s.properties" if len(os.Args) > 2 { cfg = os.Args[2] } var fcfg_s = util.NewFcfg3() fcfg_s.InitWithFilePath2(cfg, true) fcfg_s.Print() redirect_l(fcfg_s) var err = ffcm.InitDtcmS(fcfg_s, mdb.MdbH_dc, dtm.NewDoNoneH()) if err == nil { err = ffcm.RunFFCM_S_V(fcfg_s) } fmt.Println(err) smartio.ResetStd() time.Sleep(time.Second) case "-g": if len(os.Args) < 3 { usage() ef(1) return } var res, err = util.HGet("%v", os.Args[2]) if err == nil { fmt.Println(res) } else { fmt.Printf("request to %v error->%v\n", os.Args[2], err) ef(1) } default: usage() ef(1) } }
package conf import ( "github.com/Centny/gwf/util" ) var Cfg *util.Fcfg = util.NewFcfg3() func UrlRoot() string { return Cfg.Val("URL_ROOT") } func ListenAddr() string { return Cfg.Val("LISTEN_ADDR") } func DbConn() string { return Cfg.Val("DB_CONN") } func TestDbConn() string { return Cfg.Val("TEST_DB_CONN") } //get the SSO login URL. func SsoLoginUrl() string { return Cfg.Val("SSO_LOGIN_URL") } //get the SSO logout URL. func SsoLogoutUrl() string {
func TestFFCM(t *testing.T) { runtime.GOMAXPROCS(util.CPU()) // // // util.Exec("rm", "-f", "xx_*") var fcfg_s = util.NewFcfg3() fcfg_s.InitWithFilePath2("ffcm_s.properties", true) var sh = &dtcm_s_h{cw: make(chan int, 100)} var err error go func() { err := InitDtcmS(fcfg_s, dtm.MemDbc, sh) if err != nil { t.Error(err.Error()) return } err = RunFFCM_S_V(fcfg_s) if err != nil { t.Error(err.Error()) return } }() fmt.Println("xxx->") time.Sleep(1 * time.Second) go RunFFCM_C("ffcm_c.properties") time.Sleep(1 * time.Second) fmt.Println("xxxx--->a") err = SRV.AddTask("xx.mp4", "xx.mp4") if err != nil { t.Error(err.Error()) return } fmt.Println("xxxx--->b") fmt.Println("xxxx--->c") <-sh.cw <-sh.cw util.Exec("rm", "-f", "xx_*") at_ts := httptest.NewServer(SRV.AddTaskH) res, err := at_ts.G2("/addTask?args=%v,%v", "xx.mp4", "xx_x") if res.IntVal("code") != 0 { t.Error("error") return } <-sh.cw <-sh.cw var vproc = SRV.AbsL[0].(*AbsV) if _, _, _, err = vproc.Build(SRV, "xkkd", nil, "xdds"); err == nil { t.Error("error") return } ts := httptest.NewServer2(NewVideoProc(CLIENT)) ts.PostN("?tid=%v", "text/plain", bytes.NewBufferString(` `), "xxx") ts.PostN("?tid=%v&duration=1111", "text/plain", bytes.NewBufferString(` xx= progress=end `), "xxx") fmt.Println("xxxx--->d") // util.Exec("cp", "xx.mp4", "xx_mm") SRV.AddTask("xx_mm") SRV.AddTask("ffcm.sh") // // RunFFCM_S("ffcm_s.properties", dtm.MemDbc, sh) // RunFFCM_S_V(nil, dtm.MemDbc, sh) RunFFCM_C("ffcm_c.properties") // // StopFFCM_C() // StopFFCM_S() time.Sleep(2 * time.Second) // // StopFFCM_C() // StopFFCM_S() // res, err = at_ts.G2("/addTask?src=%v", "sfsd") if res.IntVal("code") == 0 { t.Error("error") return } CLIENT.Stop() SRV.Close() SRV = nil CLIENT = nil RunFFCM_S_V(nil) // // util.Exec("rm", "-f", "xx_*") }
func RunFFCM_C(cfg string) error { var fcfg = util.NewFcfg3() fcfg.InitWithFilePath2(cfg, true) fcfg.Print() return RunFFCM_Cv(fcfg) }