Commit 26f7f1d0 authored by liyuanhong's avatar liyuanhong

添加了requirements.txt 文件

parent 783a9a57
#coding:utf-8 #coding:utf-8
import binascii
import socket
from ctypes import string_at
import time
import cv2
class Protocal_1078: class Protocal_1078:
def __init__(self): def __init__(self):
......
#coding:utf-8 #coding:utf-8
import binascii
import socket
from ctypes import string_at
import time
import cv2
class Protocal_1078: class Protocal_1078:
def __init__(self): def __init__(self):
......
...@@ -19,8 +19,8 @@ class StreamH264(): ...@@ -19,8 +19,8 @@ class StreamH264():
self.channel = 1 # 频道号 self.channel = 1 # 频道号
# self.host = "10.100.11.125" # self.host = "10.100.11.125"
self.host = "10.16.12.249" # self.host = "10.16.12.249"
# self.host = "10.100.12.3" self.host = "10.100.12.3"
# self.host = "localhost" # self.host = "localhost"
self.port = 1078 self.port = 1078
self.client = None self.client = None
...@@ -575,12 +575,12 @@ class StreamH264(): ...@@ -575,12 +575,12 @@ class StreamH264():
if __name__ == "__main__": if __name__ == "__main__":
obj = StreamH264() obj = StreamH264()
obj.connectServer() obj.connectServer()
obj.setFPSVideo(30) obj.setFPSVideo(24)
obj.setFPSAudio(47) obj.setFPSAudio(54)
obj.setSendDur(0.001) obj.setSendDur(0.001)
obj.setAVChangeBySecond(2) obj.setAVChangeBySecond(2)
obj.setVideoPath("../../h264/bbb3.h264") obj.setVideoPath("../../h264/yyy.h264")
obj.setAudioPath("../../aac/bbb3.aac") obj.setAudioPath("../../aac/yyy.aac")
# obj.readStreamFromFileAndSend("../../h264/bbb.h264") # 发送视频 # obj.readStreamFromFileAndSend("../../h264/bbb.h264") # 发送视频
# obj.readAacStreamFromFileAndSend("../../aac/bbb3.aac") # 发送音频 # obj.readAacStreamFromFileAndSend("../../aac/bbb3.aac") # 发送音频
obj.sendAVStream() obj.sendAVStream()
......
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
import threading import threading
import time import time
import cv2
from lib.service.StreamH264 import StreamH264 from lib.service.StreamH264 import StreamH264
...@@ -21,6 +23,14 @@ class H264PresureTest(): ...@@ -21,6 +23,14 @@ class H264PresureTest():
self.threadInfo["sucessT"] = {} self.threadInfo["sucessT"] = {}
self.threadInfo["failT"] = {} self.threadInfo["failT"] = {}
self.threadInfoPull = {} # 存放线程集(拉流线程)
self.threadInfoPull["threadObj"] = {}
self.threadInfoPull["sucessT"] = {}
self.threadInfoPull["failT"] = {}
self.isOpenPullStream = 1 # 是否开启视频拉流 0:不 1:是
self.pullUrl = "http://10.100.11.125:8085/live?port=1985&app=vandyo&stream="
def setTerNum(self,data): def setTerNum(self,data):
self.terNum = data self.terNum = data
def setMobileStart(self,data="10000000000"): def setMobileStart(self,data="10000000000"):
...@@ -35,14 +45,32 @@ class H264PresureTest(): ...@@ -35,14 +45,32 @@ class H264PresureTest():
self.host = data self.host = data
def setPort(self,data): def setPort(self,data):
self.port = data self.port = data
def setIsOpenPullStream(self,data):
self.isOpenPullStream = data
def testService(self,cloudMirror):
def testServicePush(self,cloudMirror):
cloudMirror.sendAVStream() cloudMirror.sendAVStream()
def run(self,mobile,threadId): def testServicePull(self,mobile):
pullUrl = self.pullUrl + mobile +"-" + str(self.channel)
cap = cv2.VideoCapture(pullUrl)
while (cap.isOpened()):
ret, frame = cap.read()
if ret == False:
break
# cv2.imshow("video", frame)
# if cv2.waitKey(1)&0xFF==ord('q'):
# break
print("拉流结束")
cap.release()
cv2.destroyAllWindows()
def runPush(self,mobile,threadId):
cloudMirror = StreamH264() cloudMirror = StreamH264()
cloudMirror.setHost(self.host) cloudMirror.setHost(self.host)
cloudMirror.setPort(self.port) cloudMirror.setPort(self.port)
cloudMirror.setSendDur(0)
cloudMirror.connectServer() cloudMirror.connectServer()
cloudMirror.setFPSVideo(30) cloudMirror.setFPSVideo(30)
cloudMirror.setFPSAudio(47) cloudMirror.setFPSAudio(47)
...@@ -52,18 +80,33 @@ class H264PresureTest(): ...@@ -52,18 +80,33 @@ class H264PresureTest():
cloudMirror.setMobile(mobile) cloudMirror.setMobile(mobile)
cloudMirror.setChannel(self.channel) cloudMirror.setChannel(self.channel)
conThread = threading.Thread(target=self.testService,args=(cloudMirror,)) conThread = threading.Thread(target=self.testServicePush,args=(cloudMirror,))
self.threadInfo["threadObj"][threadId] = conThread self.threadInfo["threadObj"][threadId] = conThread
conThread.start() conThread.start()
print(threadId + "启动了:" + mobile + "-" + str(self.channel)) print(threadId + "启动了:" + mobile + "-" + str(self.channel))
def runPull(self,mobile,threadId):
pullThread = threading.Thread(target=self.testServicePull, args=(mobile,))
self.threadInfoPull["threadObj"][threadId] = pullThread
pullThread.start()
print(threadId + "启动了:" + mobile + "-" + str(self.channel))
def start(self): def start(self):
for i in range(0,self.terNum): for i in range(0,self.terNum):
mobile = self.mobileStart + i mobile = self.mobileStart + i
mobile = "0" + str(mobile) mobile = "0" + str(mobile)
threadId = "threadId__" + str(i) threadId = "threadId__" + str(i)
self.run(mobile,threadId) self.runPush(mobile,threadId)
time.sleep(0.1) time.sleep(0.01)
if self.isOpenPullStream == 1:
for j in range(0,self.terNum):
mobile = self.mobileStart + j
mobile = "0" + str(mobile)
threadPullId = "threadPullId__" + str(j)
self.runPull(mobile,threadPullId)
time.sleep(0.01)
if __name__ == "__main__": if __name__ == "__main__":
test = H264PresureTest() test = H264PresureTest()
...@@ -72,6 +115,7 @@ if __name__ == "__main__": ...@@ -72,6 +115,7 @@ if __name__ == "__main__":
test.setMobileStart(10000000000) test.setMobileStart(10000000000)
test.setChannel(1) test.setChannel(1)
test.setTerNum(20) test.setTerNum(20)
test.setIsOpenPullStream(1) # 设置是否开启拉流
test.setVideoPath("../../h264/bbb3.h264") test.setVideoPath("../../h264/bbb3.h264")
test.setAudioPath("../../aac/bbb3.aac") test.setAudioPath("../../aac/bbb3.aac")
test.start() test.start()
\ No newline at end of file
#coding: utf-8 #coding: utf-8
import binascii
def readH(): def readH():
with open("h264/aaa2.264", 'rb') as f2: with open("h264/aaa2.264", 'rb') as f2:
......
#coding: utf-8
import cv2
cap=cv2.VideoCapture("http://10.100.11.125:8085/live?port=1985&app=vandyo&stream=013146201117-1")
while (cap.isOpened()):
ret, frame = cap.read()
if ret == False:
break
# cv2.imshow("video", frame)
# if cv2.waitKey(1)&0xFF==ord('q'):
# break
print("拉流结束")
cap.release()
cv2.destroyAllWindows()
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment