Commit 126a8112 authored by liyuanhong's avatar liyuanhong

增加了视频列表上传功能

parent 8429be0b
#coding: utf-8
import hashlib
import json
import os
import sys
import threading
import time
......@@ -241,7 +242,7 @@ class HomeArea():
elif msgType == "4": # 图片抓拍
self.processPicCap(msgJson, replyMsg)
elif msgType == "5": # 视频回看
pass
self.processSeeHistoryVideo(msgJson,replyMsg)
elif msgType == "7": # 紧急救援
pass
####################################################
......@@ -337,6 +338,21 @@ class HomeArea():
replyMsg = json.dumps(replyMsg)
globalParams.camera_3.picCapture(cam,replyMsg,self.ws)
####################################################
# 处理视频回看
####################################################
def processSeeHistoryVideo(self,msgJson,replyMsg):
cam = msgJson["data"]["cam"]
fiList = self.getFileList(cam)
replyMsg["code"] = "0"
replyMsg["type"] = "5"
replyMsg["data"] = fiList
replyMsg = json.dumps(replyMsg)
self.ws.sendMsg(replyMsg)
curTime = self.getCurTime()
self.logTextCtr.WriteText(curTime + "回复消息:" + replyMsg + "\n")
####################################################
# 日志重定向到日志框
####################################################
......@@ -348,9 +364,51 @@ class HomeArea():
####################################################
# 获取视频文件列表
####################################################
def getFileList(self):
pass
def getFileList(self,cam):
dirPath = "D:/project/python/mirrorSimulator/"
dirPath = dirPath + "SDCard/video/CAM_" + str(cam) + "/"
fileList = {}
fileList["cam"] = str(cam)
fileList["files"] = []
file_names = os.listdir(dirPath)
for fn in file_names:
fileInfo = {}
timeLen = 12
fsize = os.path.getsize(dirPath + fn)
fsize = int(fsize / 1024)
fiSplit = fn.split("_")
fTime = fiSplit[3] + "-" + fiSplit[4][:-4]
fTime = fTime[:4] + "-" + fTime[4:6] + "-" + fTime[6:8] + " " + fTime[9:11] + ":" + fTime[11:13] + ":" + fTime[13:]
timeArray = time.strptime(fTime, "%Y-%m-%d %H:%M:%S")
timeStamp = int(time.mktime(timeArray))
fileInfo["fname"] = fn
fileInfo["fsize"] = str(fsize)
fileInfo["ftime"] = timeLen
fileInfo["fdate"] = timeStamp
fileInfo["fileaddress"] = dirPath + fn
fileList["files"].append(fileInfo)
return fileList
if __name__ == "__main__":
dirPath = "D:/project/python/mirrorSimulator/"
dirPath = dirPath + "SDCard/video/CAM_1/"
fileList = {}
fileList["cam"] = 1
fileList["files"] = []
file_names = os.listdir(dirPath)
for fn in file_names:
fileInfo = {}
timeLen = 12
fsize = os.path.getsize(dirPath + fn)
fsize = int(fsize / 1024)
fiSplit = fn.split("_")
fTime = fiSplit[3] + "-" + fiSplit[4][:-4]
fileInfo["fname"] = fn
fileInfo["fsize"] = fsize
fileInfo["ftime"] = timeLen
fileInfo["fdate"] = fTime
fileList["files"].append(fileInfo)
print(fileList)
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