No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

149 líneas
4.4KB

  1. # import sys
  2. # sys.path.extend(["..", "../util"])
  3. # from util.AliyunSdk import AliyunVodSdk
  4. # from concurrency.CommonThread import Common
  5. from kafka import KafkaProducer
  6. import json
  7. import threading
  8. topicName = 'dsp-alg-online-tasks'
  9. eBody = {
  10. "request_id": "d4c909912ac741ce81ccef03fd1b2ec45",
  11. "models": [
  12. {
  13. "code": "001",
  14. "categories": [{
  15. "id": "0",
  16. "config": {}
  17. },
  18. {
  19. "id": "1",
  20. "config": {}
  21. },
  22. {
  23. "id": "2",
  24. "config": {}
  25. },
  26. {
  27. "id": "3",
  28. "config": {}
  29. },
  30. {
  31. "id": "4",
  32. "config": {}
  33. },
  34. {
  35. "id": "5",
  36. "config": {}
  37. }
  38. ]
  39. }],
  40. "command": "start",
  41. "pull_url": "rtmp://live.play.t-aaron.com/live/THSAr",
  42. "push_url": "rtmp://live.push.t-aaron.com/live/THSAs",
  43. "results_base_dir": "P20220802133841159"
  44. }
  45. producer = KafkaProducer(bootstrap_servers=['192.168.11.242:9092'],
  46. value_serializer=lambda m: json.dumps(m).encode('utf-8'))
  47. future = producer.send(topicName, key=b'd4c909912ac741ce81ccef03fd1b2ec45', value=eBody)
  48. result = future.get(timeout=10)
  49. print(result)
  50. # topicName = 'dsp-alg-image-tasks'
  51. # eBody = {
  52. # "request_id": "d4c909912ac741ce81ccef03fd1b2ec46",
  53. # "models": [
  54. # {
  55. # "code": "001",
  56. # "categories": [
  57. # {
  58. # "id": "0",
  59. # "config": {}
  60. # },
  61. # {
  62. # "id": "1",
  63. # "config": {}
  64. # },
  65. # {
  66. # "id": "2",
  67. # "config": {}
  68. # },
  69. # {
  70. # "id": "3",
  71. # "config": {}
  72. # },
  73. # {
  74. # "id": "4",
  75. # "config": {}
  76. # },
  77. # {
  78. # "id": "5",
  79. # "config": {}
  80. # },
  81. # {
  82. # "id": "6",
  83. # "config": {}
  84. # },
  85. # {
  86. # "id": "7",
  87. # "config": {}
  88. # }
  89. # ]
  90. # }],
  91. # "command": "start",
  92. # "image_urls": ["https://image.t-aaron.com/P20221112103326614/2022-11-12-10-37-02_frame-3991-4291_20221112103702452021-offline-P20221112103326614-eb4467a3fe8f405ebf4c44f1b48a7e4b_OR.jpg",
  93. # "https://image.t-aaron.com/P20221112103326614/2022-11-12-10-35-09_frame-1785-2085_20221112103509952824-offline-P20221112103326614-eb4467a3fe8f405ebf4c44f1b48a7e4b_OR.jpg"],
  94. # "results_base_dir": "P20220802133841159"
  95. # }
  96. # topicName = 'dsp-alg-offline-tasks'
  97. # eBody = {
  98. # "request_id": "d4c909912ac741ce81ccef03fd1b2ec46",
  99. # "models": [
  100. # {
  101. # "code": "001",
  102. # "categories": [
  103. # {
  104. # "id": "0",
  105. # "config": {}
  106. # },
  107. # {
  108. # "id": "1",
  109. # "config": {}
  110. # },
  111. # {
  112. # "id": "2",
  113. # "config": {}
  114. # },
  115. # {
  116. # "id": "3",
  117. # "config": {}
  118. # },
  119. # {
  120. # "id": "4",
  121. # "config": {}
  122. # },
  123. # {
  124. # "id": "5",
  125. # "config": {}
  126. # },
  127. # {
  128. # "id": "6",
  129. # "config": {}
  130. # },
  131. # {
  132. # "id": "7",
  133. # "config": {}
  134. # }
  135. # ]
  136. # }],
  137. # "command": "start",
  138. # "original_url": "https://vod.play.t-aaron.com/0bc905ef5651439da2bfba8427fe467e/a76a7ebb6e3b44ef9c0c7820c7e9c574-f2d7ee90cba11aa91971d58e06d295d2-4k.mp4",
  139. # "original_type": ".mp4",
  140. # "push_url": "rtmp://live.push.t-aaron.com/live/THSAr",
  141. # "results_base_dir": "P20220802133841159"
  142. # }
  143. # producer = KafkaProducer(bootstrap_servers=['192.168.11.13:9092'],
  144. # value_serializer=lambda m: json.dumps(m).encode('utf-8'))
  145. # future = producer.send(topicName, key=b'd4c909912ac741ce81ccef03fd1b2ec46', value=eBody)
  146. # result = future.get(timeout=10)
  147. # print(result)