package service import ( "basic.com/fileServer/WeedFSClient.git" "basic.com/valib/logger.git" "encoding/base64" "strings" "time" ) /*以下属于旧版本地摄像机获取截图(国标摄像机底图无法刷新) func processphoto(cid string) (local string, err error) { var camApi dbapi.CameraApi caminfo, err := camApi.GetCameraById(cid) _ = caminfo if err != nil { return "", err } _, err = exec.LookPath("ffmpeg") if err != nil { return "", nil } //piclocal := fmt.Sprintf("%s%s.jpg", *storelocal, time.Now().String()) piclocal := fmt.Sprintf("%s.jpg", time.Now().Format("2006-01-02_15_04_05.000000000")) cmd := exec.Command("ffmpeg", "-i", caminfo.Rtsp, //"-y", "-f", "image2", "-t", "0.001", //"-vf", "select='eq(pict_type\\,I)',setpts='N/(25*TB)'", "-s", "1920*1080", piclocal) err = cmd.Run() if err != nil { //return "", err //ignore error } return piclocal, nil } */ // 调用统一接口,刷新底图(集成国标底图刷新) func UpdateCapture(camType int, rtsp string, weedfsUri string, camName string) (string, string, error) { m := Rtsp if camType == 1 { //国标摄像机 m = GB28181 } realRtsp := rtsp // 暂时添加hik平台接口的rtsp转换功能. // 汇丰需求, 需要优化为通用功能. 暂时不影响正常rtsp地址 if !strings.HasPrefix(rtsp, "rtsp://") && !strings.HasPrefix(rtsp, "/dev") { realRtsp = rtspTranslation(rtsp) } var imgByte []byte var err error if strings.Contains(realRtsp, "axis-media") { imgByte, err = FFmpegSnapshot(rtsp) } else { imgByte, err = Capture("libcffmpeg-capture.so", m, realRtsp, JPEGFileExt, 1280, 720, 10) } if err == nil { base64Str := base64.StdEncoding.EncodeToString(imgByte) weedFilePath, err := WeedFSClient.UploadFile(weedfsUri, camName+".jpg", imgByte, 5*time.Second) if err != nil { logger.Debug("UploadFile err:", err) return "", base64Str, err } else { return weedFilePath, base64Str, nil } } else { logger.Warn("capture.", err.Error()) return "", "", err } }