{"id":19703559,"url":"https://github.com/monibuca/plugin-gb28181","last_synced_at":"2025-06-21T07:36:40.808Z","repository":{"id":41857743,"uuid":"289695745","full_name":"Monibuca/plugin-gb28181","owner":"Monibuca","description":"gb28181 plugin for monibuca","archived":false,"fork":false,"pushed_at":"2024-12-13T09:09:25.000Z","size":1220,"stargazers_count":149,"open_issues_count":15,"forks_count":96,"subscribers_count":6,"default_branch":"v4","last_synced_at":"2025-05-16T06:07:41.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"agpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Monibuca.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-23T13:51:37.000Z","updated_at":"2025-04-28T00:54:23.000Z","dependencies_parsed_at":"2024-05-21T12:39:07.094Z","dependency_job_id":"7cd51b2e-d637-4cdc-bac6-170430ff0f2a","html_url":"https://github.com/Monibuca/plugin-gb28181","commit_stats":null,"previous_names":[],"tags_count":97,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monibuca%2Fplugin-gb28181","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monibuca%2Fplugin-gb28181/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monibuca%2Fplugin-gb28181/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Monibuca%2Fplugin-gb28181/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Monibuca","download_url":"https://codeload.github.com/Monibuca/plugin-gb28181/tar.gz/refs/heads/v4","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254478193,"owners_count":22077676,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T21:18:14.456Z","updated_at":"2025-05-16T06:07:46.730Z","avatar_url":"https://github.com/Monibuca.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# GB28181插件\n\n该插件提供SIP server的服务，以及流媒体服务器能力，可以将NVR和摄像头的流抓到m7s中，可获取的设备的录像数据以及访问录像视频。也可以控制摄像头的旋转、缩放等。\n\n## 插件地址\n\ngithub.com/Monibuca/plugin-gb28181\n\n## 插件引入\n\n```go\nimport (\n_ \"m7s.live/plugin/gb28181/v4\"\n)\n```\n\n## 默认插件配置\n\n```yaml\ngb28181:\n  invitemode:     1 #0、手动invite 1、表示自动发起invite，当Server（SIP）接收到设备信息时，立即向设备发送invite命令获取流,2、按需拉流，既等待订阅者触发\n  position:\n    autosubposition: false #是否自动订阅定位\n    expires: 3600s #订阅周期(单位：秒)，默认3600\n    interval: 6s #订阅间隔（单位：秒），默认6\n  sipip:          \"\" #sip服务器地址 默认 自动适配设备网段\n  serial:         \"34020000002000000001\"\n  realm:          \"3402000000\"\n  username:       \"\"\n  password:       \"\"\n  registervalidity:  60s #注册有效期\n  mediaip:          \"\" #媒体服务器地址 默认 自动适配设备网段\n  port:\n    sip: udp:5060 #sip服务器端口\n    media: tcp:58200-59200 #媒体服务器端口，用于接收设备的流\n    fdm: false #端口复用,单端口默认多路复用,多端口多路复用根据这个\n\n  removebaninterval: 10m #定时移除注册失败的设备黑名单，单位秒，默认10分钟（600秒）\n  loglevel:         info\n```\n\n**如果配置了端口范围（默认为范围端口），将采用范围端口机制，每一个流对应一个端口\n\n**注意某些摄像机没有设置用户名的地方，摄像机会以自身的国标id作为用户名，这个时候m7s会忽略使用摄像机的用户名，忽略配置的用户名**\n如果设备配置了错误的用户名和密码，连续三次上报错误后，m7s会记录设备id，并在10分钟内禁止设备注册\n\n## 插件功能\n\n### 使用SIP协议接受NVR或其他GB28181设备的注册\n\n- 服务器启动时自动监听SIP协议端口，当有设备注册时，会记录该设备信息，可以从UI的列表中看到设备\n- 定时发送Catalog命令查询设备的目录信息，可获得通道数据或者子设备\n- 发送RecordInfo命令查询设备对录像数据\n- 发送Invite命令获取设备的实时视频或者录像视频\n- 发送PTZ命令来控制摄像头云台\n- 自动同步设备位置\n\n### 作为GB28281的流媒体服务器接受设备的媒体流\n\n- 当invite设备的**实时**视频流时，会在m7s中创建对应的流，StreamPath由设备编号和通道编号组成，即[设备编号]/[通道编号],如果有多个层级，通道编号是最后一个层级的编号\n- 当invite设备的**录像**视频流时，StreamPath由设备编号和通道编号以及录像的起止时间拼接而成即[设备编号]/[通道编号]/[开始时间]-[结束时间]\n\n## 接口API\n\n### 罗列所有的gb28181协议的设备\n\n`/gb28181/api/list`\n设备的结构体如下\n\n```go\ntype Device struct {\n\tID              string\n\tName            string\n\tManufacturer    string\n\tModel           string\n\tOwner           string\n\tRegisterTime    time.Time\n\tUpdateTime      time.Time\n\tLastKeepaliveAt time.Time\n\tStatus          string\n\tChannels        []*Channel\n\tNetAddr         string\n}\n```\n\n\u003e 根据golang的规则，小写字母开头的变量不会被序列化\n\n### 从设备拉取视频流\n\n`/gb28181/api/invite`\n\n| 参数名    | 必传 | 含义                         |\n| --------- | ---- | ---------------------------- |\n| id        | 是   | 设备ID                       |\n| channel   | 是   | 通道编号                     |\n| startTime | 否   | 开始时间（纯数字Unix时间戳） |\n| endTime   | 否   | 结束时间（纯数字Unix时间戳） |\n\n返回200代表成功, 304代表已经在拉取中，不能重复拉（仅仅针对直播流）\n\n### 停止从设备拉流\n\n`/gb28181/api/bye`\n\n| 参数名  | 必传 | 含义     |\n| ------- | ---- | -------- |\n| id      | 是   | 设备ID   |\n| channel | 是   | 通道编号 |\n\nhttp 200 表示成功，404流不存在\n\n### 发送控制命令\n\n`/gb28181/api/control`\n\n| 参数名  | 必传 | 含义        |\n| ------- | ---- | ----------- |\n| id      | 是   | 设备ID      |\n| channel | 是   | 通道编号    |\n| ptzcmd  | 是   | PTZ控制指令 |\n\n### 查询录像\n\n`/gb28181/api/records`\n\n| 参数名    | 必传 | 含义                                         |\n| --------- | ---- | -------------------------------------------- |\n| id        | 是   | 设备ID                                       |\n| channel   | 是   | 通道编号                                     |\n| startTime | 否   | 开始时间（Unix时间戳） |\n| endTime   | 否   | 结束时间（Unix时间戳）                   |\n\n### 移动位置订阅\n\n`/gb28181/api/position`\n\n| 参数名   | 必传 | 含义           |\n| -------- | ---- | -------------- |\n| id       | 是   | 设备ID         |\n| expires  | 是   | 订阅周期（秒） |\n| interval | 是   | 订阅间隔（秒） |\n\n### 预置位列表查询\n\n`/gb28181/api/preset/list`\n\n| 参数名   | 必传 | 含义           |\n| -------- | ---- | -------------- |\n| id       | 是   | 设备ID         |\n| channel   | 是   | 通道编号                                     |\n\n\n### 预置位操作\n\n`/gb28181/api/preset/control`\n\n| 参数名   | 必传 | 含义                  |\n| -------- | ---- |---------------------|\n| id       | 是   | 设备ID                |\n| channel   | 是   | 通道编号                |\n| cmd | 是   | 操作指令 0=新增,1=删除,2=调用 |\n| point | 是   | 预置点位1-255           |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonibuca%2Fplugin-gb28181","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmonibuca%2Fplugin-gb28181","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmonibuca%2Fplugin-gb28181/lists"}