Commit f73d499d authored by liyuanhong's avatar liyuanhong

增加了文件文件手动上传视频文件功能

parent b60558c2
...@@ -616,12 +616,19 @@ class CameraArea(): ...@@ -616,12 +616,19 @@ class CameraArea():
else: else:
capTime = self.pushObj.getTimeStamp() capTime = self.pushObj.getTimeStamp()
capTime = int(capTime / 1000) capTime = int(capTime / 1000)
capdur = 5 capdur = 12 # 要抓拍的视频时长
inFi = self.videoPathText.GetValue() inFi = self.videoPathText.GetValue()
videoLen = self.getVideoDur(inFi) videoLen = self.getVideoDur(inFi)
curtimeO = self.getCurTimeO() curtimeO = self.getCurTimeO()
curPath = globalParams.scriptPath curPath = globalParams.scriptPath
outFi = curPath + "/SDCard/video/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".mp4" outFi = 1
if cam == 1:
outFi = curPath + "/SDCard/video/CAM_1/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".mp4"
elif cam == 2:
outFi = curPath + "/SDCard/video/CAM_2/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".mp4"
elif cam == 3:
outFi = curPath + "/SDCard/video/CAM_3/" + 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())
...@@ -647,7 +654,14 @@ class CameraArea(): ...@@ -647,7 +654,14 @@ class CameraArea():
curPath = globalParams.scriptPath 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 = 1
if cam == 1:
outFi = curPath + "/SDCard/picture/CAM_1/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".jpg"
elif cam == 2:
outFi = curPath + "/SDCard/picture/CAM_2/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".jpg"
elif cam == 3:
outFi = curPath + "/SDCard/picture/CAM_3/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".jpg"
# outFi = curPath + "/SDCard/picture/" + curtimeO + "_" + str(videoLen) + "__" + str(capTime) + ".jpg"
m_command = ["ffmpeg.exe", "-i", inFi, "-frames:v", "1", "-ss", capTime, "-f", "image2", outFi] m_command = ["ffmpeg.exe", "-i", inFi, "-frames:v", "1", "-ss", capTime, "-f", "image2", outFi]
subprocess.run(m_command) subprocess.run(m_command)
......
#coding: utf-8 #coding: utf-8
import json import json
import os
import sys import sys
import threading
import time import time
import requests import requests
import wx import wx
from pubsub import pub
from ui import globalParams from ui import globalParams
...@@ -30,6 +34,10 @@ class EventAndOtherArea(): ...@@ -30,6 +34,10 @@ class EventAndOtherArea():
self.spdlTextCtr = None # 速度设置框 self.spdlTextCtr = None # 速度设置框
self.trsComboBox = None # 定位可信度设置框 self.trsComboBox = None # 定位可信度设置框
self.videoFilePathTextCtr = None # 上传文化底子框
self.cameraTypeCombox = None # 摄像头选择框
self.videoTypeCombox = None # 上传文件类型选择框
self.logTextCtr = None # 日志输出框 self.logTextCtr = None # 日志输出框
...@@ -50,6 +58,7 @@ class EventAndOtherArea(): ...@@ -50,6 +58,7 @@ class EventAndOtherArea():
boxSizer.Add(bottomPanel,1, flag=wx.EXPAND | wx.TOP , border=5) boxSizer.Add(bottomPanel,1, flag=wx.EXPAND | wx.TOP , border=5)
self.mainPanel.SetSizer(boxSizer) self.mainPanel.SetSizer(boxSizer)
pub.subscribe(self.showLog, "showLog")
return self.mainPanel return self.mainPanel
################################################# #################################################
...@@ -105,11 +114,26 @@ class EventAndOtherArea(): ...@@ -105,11 +114,26 @@ class EventAndOtherArea():
helpButton = wx.Button(ctrlPannel, label="一键救援", pos=(170, 20)) helpButton = wx.Button(ctrlPannel, label="一键救援", pos=(170, 20))
self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.sendHelpEvt(evt), self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.sendHelpEvt(evt),
helpButton) helpButton)
videoUploadPannel = wx.StaticBox(topPanel, -1, "视频上传:", size=(wx.EXPAND, 50))
wx.StaticText(videoUploadPannel, label='文件:', pos=(10, 20))
self.videoFilePathTextCtr = wx.TextCtrl(videoUploadPannel, pos=(60, 15), size=wx.Size(350, -1))
selectFileButton = wx.Button(videoUploadPannel, label="选择文件", pos=(420, 15))
self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.selectVideoFile(evt,self.videoFilePathTextCtr),
selectFileButton)
wx.StaticText(videoUploadPannel, label='视频类型:', pos=(500, 20))
self.videoTypeCombox = wx.ComboBox(videoUploadPannel, pos=(570, 15), choices=['手动抓拍图片', '手动抓拍视频',"历史视频", \
"行车碰撞视频","停车碰撞视频","一键报警视频"], value="手动抓拍图片",size=wx.Size(100, -1))
self.cameraTypeCombox = wx.ComboBox(videoUploadPannel, pos=(680, 15), choices=['摄像头1', '摄像头2', "摄像头3", ],value="摄像头1",size=wx.Size(80, -1))
startUploadButton = wx.Button(videoUploadPannel, label="上传文件", pos=(770, 15))
self.frame.Bind(wx.EVT_BUTTON, lambda evt: self.uploadVideoFile(evt),
startUploadButton)
topPanelSizer.Add(basicInfoPanel, 0.7, flag=wx.EXPAND | wx.ALL) topPanelSizer.Add(basicInfoPanel, 0.7, flag=wx.EXPAND | wx.ALL)
topPanelSizer.Add(gpsPannel, 2, flag=wx.EXPAND | wx.ALL) topPanelSizer.Add(gpsPannel, 2, flag=wx.EXPAND | wx.ALL)
topPanelSizer.Add(ctrlPannel, 1, flag=wx.EXPAND | wx.ALL) topPanelSizer.Add(ctrlPannel, 1, flag=wx.EXPAND | wx.ALL)
otherPannel = wx.Panel(topPanel,-1, size=(wx.EXPAND, 50)) topPanelSizer.Add(videoUploadPannel, 1, flag=wx.EXPAND | wx.TOP,border=10)
topPanelSizer.Add(otherPannel, 4, flag=wx.EXPAND | wx.ALL) otherPannel = wx.Panel(topPanel, -1, size=(wx.EXPAND, 50))
topPanelSizer.Add(otherPannel, 3, flag=wx.EXPAND | wx.ALL)
topPanel.SetSizer(topPanelSizer) topPanel.SetSizer(topPanelSizer)
return topPanel return topPanel
...@@ -220,6 +244,25 @@ class EventAndOtherArea(): ...@@ -220,6 +244,25 @@ class EventAndOtherArea():
timeCur = "[" + timeCur + "] " timeCur = "[" + timeCur + "] "
return timeCur return timeCur
#################################################
# 打开文件选择对话框
#################################################
def selectVideoFile(self,evt,textCtr):
wildcard = "Video file (*.mp4)|*.mp4"
dlg = wx.FileDialog(
self.frame, message="选择flv视频文件",
defaultDir=os.getcwd(),
defaultFile="",
wildcard=wildcard,
style=wx.FD_OPEN |
wx.FD_CHANGE_DIR | wx.FD_FILE_MUST_EXIST |
wx.FD_PREVIEW
)
if dlg.ShowModal() == wx.ID_OK:
path = dlg.GetPath()
textCtr.SetValue(path)
dlg.Destroy()
################################################# #################################################
# 清空日志 # 清空日志
...@@ -287,5 +330,65 @@ class EventAndOtherArea(): ...@@ -287,5 +330,65 @@ class EventAndOtherArea():
return data return data
####################################################
# 上传视频文件
####################################################
def uploadVideoFile(self,evt):
threadObj = threading.Thread(target=self.doUploadVideoFile())
threadObj.start()
timeCur = self.getCurTimeTxt()
self.logTextCtr.WriteText(timeCur + "文件开始上传!\n")
def doUploadVideoFile(self):
params = {}
filePath = self.videoFilePathTextCtr.GetValue()
camTxt = self.cameraTypeCombox.GetValue()
cam = 1
if camTxt == "摄像头1":
cam = 1
elif camTxt == "摄像头2":
cam = 2
elif camTxt == "摄像头3":
cam = 3
iscaptureTxt = self.videoTypeCombox.GetValue()
iscapture = 1
if iscaptureTxt == "手动抓拍图片":
iscapture = 1
elif iscaptureTxt == "手动抓拍视频":
iscapture = 2
elif iscaptureTxt == "历史视频":
iscapture = 3
elif iscaptureTxt == "行车碰撞视频":
iscapture = 4
elif iscaptureTxt == "停车碰撞视频":
iscapture = 5
elif iscaptureTxt == "一键报警视频":
iscapture = 6
imei = globalParams.homeArea.getDevCodeText().GetValue()
lat = globalParams.eventArea.getLatTextCtr().GetValue()
lng = globalParams.eventArea.getLngTextCtr().GetValue()
timeCur = int(time.time())
with open(filePath, "rb") as fi:
files = {'file': fi}
params["fileaddress"] = "/aaa"
params["cam"] = cam
params["imei"] = imei
params["iscapture"] = iscapture
params["lat"] = lat
params["lng"] = lng
params["time"] = timeCur
res = requests.post("http://api-test.vandyo.com/mirror/upload/file", files=files, params=params)
curTime = self.getCurTimeTxt()
wx.CallAfter(pub.sendMessage, "showLog", msg=curTime + "视频上传完成!")
####################################################
# 用于多线程的日志展示
####################################################
def showLog(self,msg):
self.logTextCtr.WriteText(msg + "\n")
...@@ -345,6 +345,12 @@ class HomeArea(): ...@@ -345,6 +345,12 @@ class HomeArea():
sys.stdout = self.logTextCtr sys.stdout = self.logTextCtr
sys.stderr = self.logTextCtr sys.stderr = self.logTextCtr
####################################################
# 获取视频文件列表
####################################################
def getFileList(self):
pass
...@@ -64,7 +64,7 @@ class MainWindow(): ...@@ -64,7 +64,7 @@ class MainWindow():
nodeBook.AddPage(page3, "摄像头3") nodeBook.AddPage(page3, "摄像头3")
codecArea = CodecArea(nodeBook) codecArea = CodecArea(nodeBook)
page4 = codecArea.create() page4 = codecArea.create()
nodeBook.AddPage(page4, "转码工具") nodeBook.AddPage(page4, "转码相关工具")
eventAndOtherArea = EventAndOtherArea(nodeBook) eventAndOtherArea = EventAndOtherArea(nodeBook)
globalParams.eventArea = eventAndOtherArea globalParams.eventArea = eventAndOtherArea
page5 = eventAndOtherArea.create() page5 = eventAndOtherArea.create()
......
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