Commit 85f0c3a1 authored by liyuanhong's avatar liyuanhong

添加了对CompositionTime的处理

parent 4549a804
...@@ -3,6 +3,8 @@ import binascii ...@@ -3,6 +3,8 @@ import binascii
import json import json
import re import re
import time import time
import traceback
import requests import requests
from lib.protocal.Protocal_1078 import Protocal_1078 from lib.protocal.Protocal_1078 import Protocal_1078
...@@ -145,7 +147,7 @@ class StreamH264Flv(): ...@@ -145,7 +147,7 @@ class StreamH264Flv():
AVdata = AVtag[10:] # 视频数据 AVdata = AVtag[10:] # 视频数据
frameInfo = self.getVideoFrame(AVtag) frameInfo = self.getVideoFrame(AVtag)
for frame in frameInfo["frames"]: for frame in frameInfo["frames"]:
self.sendVideoFrame(frame,avTimeStamp) self.sendVideoFrame(frame,avTimeStamp,AVtag)
elif tagType == "12": # 脚本 elif tagType == "12": # 脚本
AVdata = AVtag # 脚本数据 AVdata = AVtag # 脚本数据
else: else:
...@@ -189,10 +191,11 @@ class StreamH264Flv(): ...@@ -189,10 +191,11 @@ class StreamH264Flv():
#################################################### ####################################################
# 发送视频帧 # 发送视频帧
#################################################### ####################################################
def sendVideoFrame(self,fra,timeStamp): def sendVideoFrame(self,fra,timeStamp,avTag):
self.protocal_1078.setSim(self.mobile) self.protocal_1078.setSim(self.mobile)
self.protocal_1078.setLogcC(self.channel) self.protocal_1078.setLogcC(self.channel)
self.protocal_1078.setTime(timeStamp) avTimeStamp = timeStamp + self.getCompositionTime(avTag)
self.protocal_1078.setTime(avTimeStamp)
frameType = fra[8:10] frameType = fra[8:10]
if frameType == "65": if frameType == "65":
self.videoLastKeyTime = timeStamp self.videoLastKeyTime = timeStamp
...@@ -214,6 +217,7 @@ class StreamH264Flv(): ...@@ -214,6 +217,7 @@ class StreamH264Flv():
try: try:
self.client.send(binascii.a2b_hex(msg)) self.client.send(binascii.a2b_hex(msg))
except: except:
traceback.print_exc()
print(msg) print(msg)
time.sleep(self.sendDur) time.sleep(self.sendDur)
...@@ -306,6 +310,18 @@ class StreamH264Flv(): ...@@ -306,6 +310,18 @@ class StreamH264Flv():
frameData["frames"] = [] frameData["frames"] = []
return frameData return frameData
####################################################
# 获取视频帧的CompositionTime
####################################################
def getCompositionTime(self,AVTag):
AVCPkgType = int(AVTag[2:4], 16)
compositionTime = 0
if AVCPkgType == 0:
pass
else:
compositionTime = int(AVTag[4:10],16)
return compositionTime
#################################################### ####################################################
# 根据AVtag,获取音频帧数据 # 根据AVtag,获取音频帧数据
#################################################### ####################################################
...@@ -348,7 +364,7 @@ if __name__ == "__main__": ...@@ -348,7 +364,7 @@ if __name__ == "__main__":
obj.setHost("10.100.11.125") obj.setHost("10.100.11.125")
# obj.setHost("video-test.vandyo.com") # obj.setHost("video-test.vandyo.com")
obj.setPort(1078) obj.setPort(1078)
obj.setVideoPath("../../flv/bbb3.flv") obj.setVideoPath("../../flv/aaa3.flv")
obj.connectServer() obj.connectServer()
obj.readFlvAndSend() obj.readFlvAndSend()
......
#coding: utf-8
class ClientWebSocket():
def __init__(self):
pass
\ No newline at end of file
#coding: utf-8
import wx
class CodecArea():
def __init__(self, frame):
self.frame = frame
self.mainPanel = None
#################################################
# 创建一个顶级pannel
#################################################
def create(self):
self.mainPanel = wx.Panel(self.frame)
boxSizer = wx.BoxSizer(wx.VERTICAL)
topPanel = wx.Panel(self.mainPanel)
topPanel.SetBackgroundColour("YELLOW")
bottomPanel = wx.Panel(self.mainPanel)
boxSizer.Add(topPanel,1,flag=wx.EXPAND | wx.ALL)
boxSizer.Add(bottomPanel,2, flag=wx.EXPAND | wx.TOP , border=5)
self.mainPanel.SetSizer(boxSizer)
return self.mainPanel
\ No newline at end of file
#coding: utf-8
import wx
class EventAndOtherArea():
def __init__(self, frame):
self.frame = frame
self.mainPanel = None
#################################################
# 创建一个顶级pannel
#################################################
def create(self):
self.mainPanel = wx.Panel(self.frame)
boxSizer = wx.BoxSizer(wx.VERTICAL)
topPanel = wx.Panel(self.mainPanel)
topPanel.SetBackgroundColour("GREEN")
bottomPanel = wx.Panel(self.mainPanel)
boxSizer.Add(topPanel,1,flag=wx.EXPAND | wx.ALL)
boxSizer.Add(bottomPanel,2, flag=wx.EXPAND | wx.TOP , border=5)
self.mainPanel.SetSizer(boxSizer)
return self.mainPanel
\ No newline at end of file
#coding: utf-8
import wx
class HomeArea():
def __init__(self, frame):
self.frame = frame
self.mainPanel = None
#################################################
# 创建一个顶级pannel
#################################################
def create(self):
self.mainPanel = wx.Panel(self.frame)
boxSizer = wx.BoxSizer(wx.VERTICAL)
topPanel = wx.Panel(self.mainPanel)
topPanel.SetBackgroundColour("PINK")
bottomPanel = wx.Panel(self.mainPanel)
boxSizer.Add(topPanel,1,flag=wx.EXPAND | wx.ALL)
boxSizer.Add(bottomPanel,2, flag=wx.EXPAND | wx.TOP , border=5)
self.mainPanel.SetSizer(boxSizer)
return self.mainPanel
\ No newline at end of file
...@@ -3,6 +3,9 @@ ...@@ -3,6 +3,9 @@
import wx import wx
from ui.CameraArea import CameraArea from ui.CameraArea import CameraArea
from ui.CodecArea import CodecArea
from ui.EventAndOtherArea import EventAndOtherArea
from ui.HomeArea import HomeArea
''' '''
定义主窗体 定义主窗体
...@@ -37,8 +40,11 @@ class MainWindow(): ...@@ -37,8 +40,11 @@ class MainWindow():
boxSizer = wx.BoxSizer(wx.VERTICAL) boxSizer = wx.BoxSizer(wx.VERTICAL)
nodeBook = wx.Notebook(mainPanel) nodeBook = wx.Notebook(mainPanel)
cameraArea1 = CameraArea(nodeBook) homeArea = HomeArea(nodeBook)
page0 = homeArea.create()
nodeBook.AddPage(page0, "云镜首页")
cameraArea1 = CameraArea(nodeBook)
page1 = cameraArea1.create() page1 = cameraArea1.create()
nodeBook.AddPage(page1,"摄像头1") nodeBook.AddPage(page1,"摄像头1")
...@@ -51,11 +57,14 @@ class MainWindow(): ...@@ -51,11 +57,14 @@ class MainWindow():
cameraArea3.setChannel(3) cameraArea3.setChannel(3)
page3 = cameraArea3.create() page3 = cameraArea3.create()
nodeBook.AddPage(page3, "摄像头3") nodeBook.AddPage(page3, "摄像头3")
page4 = wx.Panel(nodeBook) codecArea = CodecArea(nodeBook)
page4 = codecArea.create()
nodeBook.AddPage(page4, "转码工具") nodeBook.AddPage(page4, "转码工具")
page5 = wx.Panel(nodeBook) eventAndOtherArea = EventAndOtherArea(nodeBook)
page5 = eventAndOtherArea.create()
nodeBook.AddPage(page5, "告警与其他功能") nodeBook.AddPage(page5, "告警与其他功能")
boxSizer.Add(nodeBook, 1, flag=wx.EXPAND | wx.ALL) boxSizer.Add(nodeBook, 1, flag=wx.EXPAND | wx.ALL)
nodeBook.SetSelection(1)
mainPanel.SetSizer(boxSizer) mainPanel.SetSizer(boxSizer)
......
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