Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
M
mirrorSimulator
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李远洪
mirrorSimulator
Commits
9fc6bbb8
Commit
9fc6bbb8
authored
Dec 31, 2020
by
liyuanhong
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
更新了UI操作
parent
452f5bbf
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
201 additions
and
56 deletions
+201
-56
config/config.yaml
config/config.yaml
+2
-0
lib/service/StreamH264Flv.py
lib/service/StreamH264Flv.py
+47
-28
start.py
start.py
+5
-0
ui/CameraArea.py
ui/CameraArea.py
+147
-28
No files found.
config/config.yaml
0 → 100644
View file @
9fc6bbb8
globalCon
:
getPlayUrl
:
http://10.100.11.110:9999/video/streamInfo
lib/service/StreamH264Flv.py
View file @
9fc6bbb8
...
...
@@ -23,6 +23,7 @@ class StreamH264Flv():
self
.
mobile
=
"013146201117"
# 手机号
self
.
channel
=
1
# 频道号
self
.
isSendAudio
=
1
# 是否发送音频0:不发送 1:发送
self
.
isSend
=
0
# 是否发送消息 0:不发送 1:发送
# self.host = "10.100.11.125" # 开发环境
self
.
host
=
"10.100.12.3"
# 测试环境
...
...
@@ -33,6 +34,7 @@ class StreamH264Flv():
self
.
isGetPlayUrl
=
0
# 是否已经获取了playUrl 0:没有 1:获取了
self
.
playUrl
=
""
# 视频播放地址
def
setMobile
(
self
,
data
):
self
.
mobile
=
data
def
setChannel
(
self
,
data
):
...
...
@@ -63,10 +65,17 @@ class StreamH264Flv():
# self.client.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1) # 在客户端开启心跳
# self.client.connect((self.host, self.port))
####################################################
# socket 断开
####################################################
def
disConnectServer
(
self
):
self
.
client
.
close
()
####################################################
# 读取flv文件,并发送 (h264编码,并且音频为aac编码格式)
####################################################
def
readFlvAndSend
(
self
):
self
.
isSend
=
1
with
open
(
self
.
videoPath
,
'rb'
)
as
fi
:
con
=
fi
.
read
(
self
.
readSize
)
data
=
con
.
hex
()
...
...
@@ -76,40 +85,50 @@ class StreamH264Flv():
else
:
data
=
data
while
con
:
if
len
(
data
)
<
30
:
con
=
fi
.
read
(
self
.
readSize
)
data
=
data
+
con
.
hex
()
else
:
tagSize
=
self
.
getAVTagSize
(
data
)
if
len
(
data
)
<
(
tagSize
*
2
+
30
):
if
self
.
isSend
==
1
:
if
len
(
data
)
<
30
:
con
=
fi
.
read
(
self
.
readSize
)
data
=
data
+
con
.
hex
()
else
:
tag
=
data
[:
tagSize
*
2
+
30
]
# flv tag
tagType
=
self
.
getTagType
(
tag
)
# flv tag 类型,是音频 还是视频
AVtag
=
tag
[
30
:]
# 音视频 tag
avTimeStamp
=
self
.
getAVTimeStamp
(
tag
)
#获取时间戳
if
avTimeStamp
>
100
:
if
self
.
isGetPlayUrl
==
0
:
self
.
getPlayUrl
(
self
.
mobile
,
self
.
channel
)
self
.
isGetPlayUrl
=
1
if
tagType
==
"08"
:
# 音频
AVdata
=
AVtag
[
4
:]
# 音频数据
frameInfo
=
self
.
getAudioFrame
(
AVtag
)
for
frame
in
frameInfo
[
"frames"
]:
self
.
sendAudioFrame
(
frame
,
avTimeStamp
)
elif
tagType
==
"09"
:
# 视频
AVdata
=
AVtag
[
10
:]
# 视频数据
frameInfo
=
self
.
getVideoFrame
(
AVtag
)
for
frame
in
frameInfo
[
"frames"
]:
self
.
sendVideoFrame
(
frame
,
avTimeStamp
)
elif
tagType
==
"12"
:
# 脚本
AVdata
=
AVtag
# 脚本数据
tagSize
=
self
.
getAVTagSize
(
data
)
if
len
(
data
)
<
(
tagSize
*
2
+
30
):
con
=
fi
.
read
(
self
.
readSize
)
data
=
data
+
con
.
hex
()
else
:
AVdata
=
AVtag
data
=
data
[(
tagSize
*
2
+
30
):]
tag
=
data
[:
tagSize
*
2
+
30
]
# flv tag
tagType
=
self
.
getTagType
(
tag
)
# flv tag 类型,是音频 还是视频
AVtag
=
tag
[
30
:]
# 音视频 tag
avTimeStamp
=
self
.
getAVTimeStamp
(
tag
)
#获取时间戳
if
avTimeStamp
>
100
:
if
self
.
isGetPlayUrl
==
0
:
self
.
getPlayUrl
(
self
.
mobile
,
self
.
channel
)
self
.
isGetPlayUrl
=
1
if
tagType
==
"08"
:
# 音频
AVdata
=
AVtag
[
4
:]
# 音频数据
if
self
.
isSendAudio
==
1
:
frameInfo
=
self
.
getAudioFrame
(
AVtag
)
for
frame
in
frameInfo
[
"frames"
]:
self
.
sendAudioFrame
(
frame
,
avTimeStamp
)
elif
tagType
==
"09"
:
# 视频
AVdata
=
AVtag
[
10
:]
# 视频数据
frameInfo
=
self
.
getVideoFrame
(
AVtag
)
for
frame
in
frameInfo
[
"frames"
]:
self
.
sendVideoFrame
(
frame
,
avTimeStamp
)
elif
tagType
==
"12"
:
# 脚本
AVdata
=
AVtag
# 脚本数据
else
:
AVdata
=
AVtag
data
=
data
[(
tagSize
*
2
+
30
):]
else
:
time
.
sleep
(
1
)
self
.
client
.
close
()
####################################################
# 停止发送消息
####################################################
def
stopSend
(
self
):
self
.
isSend
=
0
####################################################
# 获取视频播放地址
####################################################
...
...
start.py
0 → 100644
View file @
9fc6bbb8
#coding: utf-8
from
ui.MainWindow
import
MainWindow
if
__name__
==
"__main__"
:
MainWindow
()
.
show
()
\ No newline at end of file
ui/CameraArea.py
View file @
9fc6bbb8
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment