推流地址

文件目录:org.jeecg.modules.demo.apimanage.service
image.png

  1. /**
  2. * 查询推流状态
  3. */
  4. public ResponseResult selectPush(JSONObject jsonObject) {
  5. String cloudEyeId = String.valueOf(jsonObject.get("cloudEyeId"));
  6. ResponseResult res = CheckParam.startCheck(cloudEyeId);
  7. if (res != null) {
  8. return res;
  9. }
  10. Nhiotcloudeyelive Nhiotcloudeyelive = iNhiotcloudeyeliveService.selectCloudeyeLive(cloudEyeId);
  11. if (Nhiotcloudeyelive != null) {
  12. return ResponseResult.success(Nhiotcloudeyelive);
  13. }
  14. return ResponseResult.error(ResponseResultEnum.ERROR);
  15. }
  16. public static long timeConversion(int startTime) {
  17. //10位时间戳
  18. String timestamp = null;
  19. long s = 0;
  20. try {
  21. if (startTime == 10) {
  22. startTime = 0;
  23. }
  24. Long time = System.currentTimeMillis();
  25. time += startTime * 1000 * 60; //当前时间加上30分钟
  26. s = (new Date(time).getTime() / 1000);
  27. } catch (Exception e) {
  28. System.out.println(e);
  29. }
  30. return s;
  31. }
  32. /**
  33. * 0FA023H243JJ32J2BK
  34. * 推流拼接
  35. */
  36. public ResponseResult cloudeyeDevicePush(JSONObject jsonObject) {
  37. String cloudEyeId = String.valueOf(jsonObject.get("cloudEyeId"));
  38. /*String starTime = String.valueOf(jsonObject.get("starTime"));*/
  39. /*int lapseTime = Integer.valueOf(starTime);*/
  40. // push 时间戳
  41. String pushTime = "4093676538";
  42. // 时间戳
  43. /*long time = timeConversion(lapseTime);*/
  44. long time=4102316538L;
  45. // APP名称
  46. String appName = "nhyy";
  47. // 摄像头编号名称
  48. String streamName = cloudEyeId;
  49. // 播流域名
  50. String playHost = "p.nonghi.net";
  51. // 推流域名
  52. String pushHost = "t.nonghi.net";
  53. // 鉴权主key
  54. String pushKye = "PKNZ5ZQVSA";
  55. // 鉴权主key
  56. String playKye = "lcWY04vIoI";
  57. // 随机数不要有下划线
  58. String rand = UUIDGenerator.generate();
  59. // 加密
  60. String strPlay = "/" + appName + "/" + streamName + "-" + time + "-0-0-" + playKye;
  61. String m3u8s = "/" + appName + "/" + streamName + ".m3u8" + "-" + time + "-0-0-" + playKye;
  62. String strPush = "/" + appName + "/" + streamName + "-" + pushTime + "-0-0-" + pushKye;
  63. // 播放流拼接rtmp
  64. String playUrl = "rtmp://" + playHost + "/" + appName + "/" + streamName + "?auth_key=" + time + "-0-0-" + DigestUtils.md5Hex(strPlay);
  65. String m3u8Url = "http://" + playHost + "/" + appName + "/" + streamName+ ".m3u8" + "?auth_key=" + time + "-0-0-" + DigestUtils.md5Hex(m3u8s);
  66. // 推流拼接rtmp
  67. String pushUrl = "rtmp://" + pushHost + "/" + appName + "/" + streamName + "?auth_key=" + pushTime + "-0-0-" + DigestUtils.md5Hex(strPush);
  68. String m3u8 = "http://" + playHost + "/" + "video/record/live/SSSS-515778-DAAEC/2020-03-17-19-03-27_2020-03-17-19-18-27.m3u8" + "?auth_key=" + time + "-0-0-" + DigestUtils.md5Hex(m3u8s);
  69. System.out.println(">>>>>>>>>>>>>>>播流地址RTMP" + playUrl);
  70. System.out.println(">>>>>>>>>>>>>>>播流地址M3U8" + m3u8Url);
  71. System.out.println(">>>>>>>>>>>>>>>推流地址RTMP" + pushUrl);
  72. return ResponseResult.success(playUrl);
  73. }
  74. /**
  75. * 推流生成
  76. *
  77. * @param
  78. * @return
  79. */
  80. public String setPushUrl(String uid) {
  81. // 时间戳
  82. String pushTime = "1767252141";
  83. // APP名称
  84. String appName = "nhyy";
  85. // 摄像头编号名称
  86. String streamName = uid;
  87. // 推流域名
  88. String pushHost = "t.nonghi.net";
  89. // 鉴权主key
  90. String pushKye = "PKNZ5ZQVSA";
  91. // 加密
  92. String strPush = "/" + appName + "/" + streamName + "-" + pushTime + "-0-0-" + pushKye;
  93. // 推流拼接rtmp
  94. String pushUrl = "rtmp://" + pushHost + "/" + appName + "/" + streamName + "?auth_key=" + pushTime + "-0-0-" + DigestUtils.md5Hex(strPush);
  95. return pushUrl;
  96. }

FTP设置

摄像头配置报警设置上传图片和视频到FTP:

1.使用控制台 添加两个摄像头 点击下方设置
image.png

image.png

配置FTP:

上传的FTP目录
地址:47.92.34.148
账号:pic_nonghi_net
密码:aRYWzNsSW6sxLyNa
上传的目录:/pic/SSAA-016894-ECFCA 重点(用pic_nonghi_net账号登录以后找到PIC目录 摄像头名称不用手动创建只需要配置后自动创建)

查看配置是否成功:

如果配置成功后进入FTP目录会看到该文件夹下出现的images文件夹然后该文件夹会生成T开头的文件,该文件是测试文件

image.png

直播

获取直播拉流

简要描述:

  • 获取直播拉流

请求URL:

  • [https://wlw.nonghi.net/nonghi-boot/a/common/iotCloudEye/api](https://wlw.nonghi.net/nonghi-boot/a/common/iotCloudEye/api)

请求方式:

  • POST

参数:

参数名 必选 类型 说明
key int 4018
cloudEyeId string 摄像头id
starTime string 失效时间 列如10分钟传10 该参数暂时没有作用

返回示例

  1. {
  2. "result": "rtmp://p.nonghi.net/live/SSSS-515776-CBAAD?auth_key=1583906017-0-0-c83210e70667572ca8ce9508a75caa34",
  3. "code": 1,
  4. "msg": "请求成功"
  5. }

返回参数说明

参数名 类型 说明
result String 播流地址

备注