Commit b60558c2 authored by liyuanhong's avatar liyuanhong

修改了视频抓拍和图片抓拍的兼容性问题

parent 88564035
...@@ -13,6 +13,7 @@ from pubsub import pub ...@@ -13,6 +13,7 @@ from pubsub import pub
from lib.protocal.Protocal_1078 import Protocal_1078 from lib.protocal.Protocal_1078 import Protocal_1078
from lib.socket.ClientSocket import ClientSocket from lib.socket.ClientSocket import ClientSocket
from ui import globalParams
class StreamH264Flv(): class StreamH264Flv():
...@@ -36,8 +37,9 @@ class StreamH264Flv(): ...@@ -36,8 +37,9 @@ class StreamH264Flv():
self.videoPath = "../../flv/bbb3.flv" # 要推流的视频路劲 self.videoPath = "../../flv/bbb3.flv" # 要推流的视频路劲
self.getGetPlayUrl = "http://10.100.11.110:9999/video/streamInfo" # 获取推流播放地址的url self.getGetPlayUrl = "http://10.100.11.110:9999/video/streamInfo" # 获取推流播放地址的url
# self.getGetPlayUrl = "http://fb-test.vandyo.com/video/streamInfo" # 获取推流播放地址的url # self.getGetPlayUrl = "http://fb-test.vandyo.com/video/streamInfo" # 获取推流播放地址的url
curPath = sys.path[0] # curPath = sys.path[0]
with open(curPath + "/config/config.yaml", 'r', encoding="utf-8") as fi: # with open(curPath + "/config/config.yaml", 'r', encoding="utf-8") as fi:
with open(globalParams.scriptPath + "/config/config.yaml", 'r', encoding="utf-8") as fi:
fi_data = fi.read() fi_data = fi.read()
data = yaml.load(fi_data,Loader=yaml.FullLoader) data = yaml.load(fi_data,Loader=yaml.FullLoader)
self.getGetPlayUrl = data["globalCon"]["getPlayUrl"] self.getGetPlayUrl = data["globalCon"]["getPlayUrl"]
......
#coding: utf-8 #coding: utf-8
import os
from ui.MainWindow import MainWindow from ui.MainWindow import MainWindow
from ui import globalParams
if __name__ == "__main__": if __name__ == "__main__":
globalParams.scriptPath = os.getcwd()
MainWindow().show() MainWindow().show()
\ No newline at end of file
...@@ -30,8 +30,10 @@ class CameraArea(): ...@@ -30,8 +30,10 @@ class CameraArea():
self.host="10.100.11.125" self.host="10.100.11.125"
self.port="1078" self.port="1078"
curPath = sys.path[0] # curPath = sys.path[0]
with open(curPath + "/config/config.yaml", 'r', encoding="utf-8") as fi: # with open(curPath + "/config/config.yaml", 'r', encoding="utf-8") as fi:
with open(globalParams.scriptPath + "/config/config.yaml", 'r', encoding="utf-8") as fi:
fi_data = fi.read() fi_data = fi.read()
data = yaml.load(fi_data,Loader=yaml.FullLoader) data = yaml.load(fi_data,Loader=yaml.FullLoader)
self.getGetPlayUrl = data["globalCon"]["getPlayUrl"] self.getGetPlayUrl = data["globalCon"]["getPlayUrl"]
...@@ -549,10 +551,11 @@ class CameraArea(): ...@@ -549,10 +551,11 @@ class CameraArea():
# 获取视频时长 # 获取视频时长
#################################################### ####################################################
def getVideoDur(self,theFile): def getVideoDur(self,theFile):
cmd = 'ffprobe.exe -show_format ' + theFile cmd = globalParams.scriptPath + '/ffprobe.exe -show_format ' + theFile
p = subprocess.Popen(cmd, p = subprocess.Popen(cmd,
stdout=subprocess.PIPE, stdout=subprocess.PIPE,
stderr=subprocess.PIPE, stderr=subprocess.PIPE,
stdin=subprocess.DEVNULL,
shell=True shell=True
) )
p.wait() p.wait()
...@@ -617,13 +620,14 @@ class CameraArea(): ...@@ -617,13 +620,14 @@ class CameraArea():
inFi = self.videoPathText.GetValue() inFi = self.videoPathText.GetValue()
videoLen = self.getVideoDur(inFi) videoLen = self.getVideoDur(inFi)
curtimeO = self.getCurTimeO() curtimeO = self.getCurTimeO()
curPath = sys.path[0] curPath = globalParams.scriptPath
outFi = curPath + "/SDCard/video/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".mp4" outFi = curPath + "/SDCard/video/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".mp4"
self.splitVideo(capTime, capdur,inFi, outFi) self.splitVideo(capTime, capdur,inFi, outFi)
timeCur = int(time.time()) timeCur = int(time.time())
self.uploadFile(cam, outFi, 2, timeCur) self.uploadFile(cam, outFi, 2, timeCur)
ws.sendMsg(replyMsg) ws.sendMsg(replyMsg)
wx.CallAfter(pub.sendMessage, "showLog" + str(self.channel), msg=cutTime + "视频抓拍完成!")
#################################################### ####################################################
...@@ -640,7 +644,7 @@ class CameraArea(): ...@@ -640,7 +644,7 @@ class CameraArea():
else: else:
capTime = str(int(self.pushObj.getTimeStamp() / 1000)) capTime = str(int(self.pushObj.getTimeStamp() / 1000))
inFi = self.videoPathText.GetValue() inFi = self.videoPathText.GetValue()
curPath = sys.path[0] curPath = globalParams.scriptPath
videoLen = self.getVideoDur(inFi) videoLen = self.getVideoDur(inFi)
curtimeO = self.getCurTimeO() curtimeO = self.getCurTimeO()
outFi = curPath + "/SDCard/picture/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".jpg" outFi = curPath + "/SDCard/picture/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".jpg"
...@@ -650,3 +654,4 @@ class CameraArea(): ...@@ -650,3 +654,4 @@ class CameraArea():
timeCur = int(time.time()) timeCur = int(time.time())
self.uploadFile(cam,outFi,1,timeCur) self.uploadFile(cam,outFi,1,timeCur)
ws.sendMsg(replyMsg) ws.sendMsg(replyMsg)
wx.CallAfter(pub.sendMessage, "showLog" + str(self.channel), msg=cutTime + "图片抓拍完成!")
...@@ -6,4 +6,5 @@ camera_2 = None # 相机2 ...@@ -6,4 +6,5 @@ camera_2 = None # 相机2
camera_3 = None # 相机3 camera_3 = None # 相机3
eventArea = None # 事件发送对象 eventArea = None # 事件发送对象
isLogRedirect = 0 # 日志是否重定向到日志文本框 0: 不重定向 (用于调试) 1:重定向 (用于给别人用) isLogRedirect = 1 # 日志是否重定向到日志文本框 0: 不重定向 (用于调试) 1:重定向 (用于给别人用)
scriptPath = "" # 脚本执行的目录
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