Commit 8429be0b authored by liyuanhong's avatar liyuanhong

修复了文件上传失败的bug

parent f60d38f1
......@@ -621,9 +621,12 @@ class CameraArea():
imei = globalParams.homeArea.getDevCodeText().GetValue()
lat = globalParams.eventArea.getLatTextCtr().GetValue()
lng = globalParams.eventArea.getLngTextCtr().GetValue()
fsize = os.path.getsize(filePath)
fsize = int(fsize / 1024)
with open(filePath,"rb") as fi:
files = {'file': fi}
params["fileaddress"] = "/aaa"
params["fsize"] = fsize
params["fileaddress"] = filePath
params["cam"] = cam
params["imei"] = imei
params["iscapture"] = iscapture
......@@ -650,13 +653,13 @@ class CameraArea():
theDate = self.getCurDate() # 视频抓拍日期
theTime = self.getCurTheTume() # 视频抓拍时间
videoLen = self.getVideoDur(inFi) # 视频总时长
capTime = str(int(self.pushObj.getTimeStamp() / 1000)) # 从第几秒开始截取的
capTime = int(self.pushObj.getTimeStamp() / 1000) # 从第几秒开始截取的
if cam == 1:
outFi = curPath + "/SDCard/picture/CAM_1/" + "VID" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".mp4"
outFi = curPath + "/SDCard/video/CAM_1/" + "VID_" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".mp4"
elif cam == 2:
outFi = curPath + "/SDCard/picture/CAM_2/" + "VID" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".mp4"
outFi = curPath + "/SDCard/video/CAM_2/" + "VID_" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".mp4"
elif cam == 3:
outFi = curPath + "/SDCard/picture/CAM_3/" + "VID" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".mp4"
outFi = curPath + "/SDCard/video/CAM_3/" + "VID_" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".mp4"
self.splitVideo(capTime, capdur,inFi, outFi)
timeCur = int(time.time())
self.uploadFile(cam, outFi, 2, timeCur)
......@@ -670,7 +673,6 @@ class CameraArea():
def picCapture(self,cam,replyMsg,ws):
threadObj = threading.Thread(target=self.doPicCapture,args=(cam,replyMsg,ws,))
threadObj.start()
#"ffmpeg -i bbb.mp4 -frames:v 1 -ss 40 -f image2 bbb.jpg"
def doPicCapture(self,cam,replyMsg,ws):
cutTime = self.getCurTime()
if self.pushObj == None:
......@@ -684,11 +686,11 @@ class CameraArea():
videoLen = self.getVideoDur(inFi) # 视频总时长
capTime = str(int(self.pushObj.getTimeStamp() / 1000)) # 从第几秒开始截取的
if cam == 1:
outFi = curPath + "/SDCard/picture/CAM_1/" + "PIC" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".jpg"
outFi = curPath + "/SDCard/picture/CAM_1/" + "PIC_" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".jpg"
elif cam == 2:
outFi = curPath + "/SDCard/picture/CAM_2/" + "PIC" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".jpg"
outFi = curPath + "/SDCard/picture/CAM_2/" + "PIC_" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".jpg"
elif cam == 3:
outFi = curPath + "/SDCard/picture/CAM_3/" + "PIC" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".jpg"
outFi = curPath + "/SDCard/picture/CAM_3/" + "PIC_" + str(videoLen) + "_" + str(capTime) + "_" + theDate + "_" + theTime + ".jpg"
m_command = ["ffmpeg.exe", "-i", inFi, "-frames:v", "1", "-ss", capTime, "-f", "image2", outFi]
subprocess.run(m_command)
......
......@@ -248,7 +248,7 @@ class EventAndOtherArea():
# 打开文件选择对话框
#################################################
def selectVideoFile(self,evt,textCtr):
wildcard = "Video file (*.mp4)|*.mp4"
wildcard = "Video file (*.mp4;*.jpg)|*.mp4;*.jpg"
dlg = wx.FileDialog(
self.frame, message="选择flv视频文件",
defaultDir=os.getcwd(),
......@@ -370,10 +370,12 @@ class EventAndOtherArea():
lat = globalParams.eventArea.getLatTextCtr().GetValue()
lng = globalParams.eventArea.getLngTextCtr().GetValue()
timeCur = int(time.time())
fsize = os.path.getsize(filePath)
fsize = int(fsize / 1024)
with open(filePath, "rb") as fi:
files = {'file': fi}
params["fileaddress"] = "/aaa"
params["fileaddress"] = filePath
params["fsize"] = fsize
params["cam"] = cam
params["imei"] = imei
params["iscapture"] = iscapture
......
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