zhangmeng
2021-05-25 23c29d81f2c917bbb80fbfbeb285bb45a159331a
capture.go
@@ -38,12 +38,41 @@
   InvalidFileExt PicExt = PicExt("")
)
// capture pic
func captureGB28181(soFile string, url string, maxTry int) ([]byte, error) {
   var ret []byte
   var err error
   err = goffmpeg.InitFFmpeg(soFile)
   if err != nil {
      return nil, err
   }
   reterr := errors.New(fmt.Sprintf("gb28181 try %d times to capture image, is url correct?", maxTry))
   // for i := 0; i < maxTry; i++ {
   ret = goffmpeg.GetGBJpg(url, maxTry)
   if len(ret) > 0 {
      reterr = nil
      break
   }
   // }
   goffmpeg.FreeFFmpeg()
   return ret, reterr
}
// Capture pic
func Capture(soFile string, m StreamMode, url string, ext PicExt, w, h, maxTry int) ([]byte, error) {
   if m != GB28181 && m != Rtsp {
      return nil, errors.New("there is no this mode, try capture.Rtsp/capture.GB28181")
   }
   if m == GB28181 {
      return captureGB28181(soFile, url, maxTry)
   }
   if ext == InvalidFileExt {
      ext = JPEGFileExt
   }