1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
| package service
|
| import (
| "basic.com/fileServer/WeedFSClient.git"
| "basic.com/valib/logger.git"
| "encoding/base64"
| "errors"
| "time"
| "vamicro/gb28181-service/models"
| )
|
| /*以下属于旧版本地摄像机获取截图(国标摄像机底图无法刷新)
| 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
| }
| b, err := Capture("libcffmpeg-capture.so", m, rtsp, JPEGFileExt, 1280, 720, 10)
| if err == nil {
| base64Str := base64.StdEncoding.EncodeToString(b)
| weedFilePath, err := WeedFSClient.UploadFile(weedfsUri, camName+".jpg", b, 5*time.Second)
| if err != nil {
| logger.Debug("UploadFile err:", err)
| return "", base64Str, err
| } else {
| return weedFilePath, base64Str, nil
| }
| } else {
| return "", "", err
| }
| }
|
| //只获取底图byte数组,不存储到图片服务器
| func CaptureBase64(cid string) ([]byte, error) {
| var vssE models.VssChannel
| if !vssE.Exist(cid) {
| return nil, errors.New("此国标摄像机不存在")
| }
|
| if vssE.RealRtspUrl == "" {
| return nil, errors.New("rtsp地址为空")
| }
| return Capture("libcffmpeg-capture.so", GB28181, vssE.RealRtspUrl, JPEGFileExt, 1280, 720, 10)
| }
|
|