Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myc42351781
SimpleVideoServer
提交
fc529b07
S
SimpleVideoServer
项目概览
myc42351781
/
SimpleVideoServer
与 Fork 源项目一致
Fork自
云逸之 / SimpleVideoServer
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
S
SimpleVideoServer
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
fc529b07
编写于
2月 10, 2023
作者:
云逸之
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
加入延时超时后跳帧
上级
442ffa14
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
55 addition
and
19 deletion
+55
-19
simpleVideoRecorder/platformio.ini
simpleVideoRecorder/platformio.ini
+2
-2
simpleVideoRecorder/src/simpleVideoRecorder.cpp
simpleVideoRecorder/src/simpleVideoRecorder.cpp
+1
-1
src/light-video.properties
src/light-video.properties
+1
-0
src/org/btik/server/video/UDP2Main.java
src/org/btik/server/video/UDP2Main.java
+2
-1
src/org/btik/server/video/device/iface/HttpConstant.java
src/org/btik/server/video/device/iface/HttpConstant.java
+6
-6
src/org/btik/server/video/device/udp2/BufferPool.java
src/org/btik/server/video/device/udp2/BufferPool.java
+4
-0
src/org/btik/server/video/device/udp2/FrameBuffer.java
src/org/btik/server/video/device/udp2/FrameBuffer.java
+4
-2
src/org/btik/server/video/device/udp2/NewUDPDeviceChannel.java
...rg/btik/server/video/device/udp2/NewUDPDeviceChannel.java
+28
-1
src/org/btik/server/video/device/udp2/bind/DeviceSnChannelBinder.java
.../server/video/device/udp2/bind/DeviceSnChannelBinder.java
+1
-1
src/org/btik/server/video/device/web/BioHttpVideoServer.java
src/org/btik/server/video/device/web/BioHttpVideoServer.java
+3
-3
src/org/btik/server/video/device/web/MJPEGVideoChannel.java
src/org/btik/server/video/device/web/MJPEGVideoChannel.java
+3
-2
未找到文件。
simpleVideoRecorder/platformio.ini
浏览文件 @
fc529b07
...
...
@@ -41,6 +41,6 @@ build_flags = -DOVER_LOAD_CAM_CONF
;-DCORE_DEBUG_LEVEL=ARDUHAL_LOG_LEVEL_VERBOSE
; 指定帧大小
;-DFRAMESIZE=FRAMESIZE_HVGA
;
-DFRAMESIZE=FRAMESIZE_VGA
-DFRAMESIZE
=
FRAMESIZE_SVGA
-DFRAMESIZE
=
FRAMESIZE_VGA
;
-DFRAMESIZE=FRAMESIZE_SVGA
;
-DFRAMESIZE
=
FRAMESIZE_HD
\ No newline at end of file
simpleVideoRecorder/src/simpleVideoRecorder.cpp
浏览文件 @
fc529b07
...
...
@@ -5,7 +5,7 @@
#ifndef OVER_LOAD_CAM_CONF
#define CAMERA_MODEL_AI_THINKER
#define FRAMESIZE FRAMESIZE_
S
VGA
#define FRAMESIZE FRAMESIZE_VGA
//#define HE_ZHOU_S3
#endif
...
...
src/light-video.properties
浏览文件 @
fc529b07
...
...
@@ -3,6 +3,7 @@ http.port=8003
http.clients.limit
=
10
stream.port
=
8004
stream.bind.port
=
8004
frame.delay.skip.timeout
=
3000
udp.video.buffer.pool.size
=
500
udp.video.dispatcher.thread.size
=
8
udp.video.channel.size
=
128
\ No newline at end of file
src/org/btik/server/video/UDP2Main.java
浏览文件 @
fc529b07
...
...
@@ -38,7 +38,7 @@ public class UDP2Main {
}
public
static
void
main
(
String
[]
args
)
{
System
.
out
.
println
(
"
version:"
+
version
);
System
.
out
.
println
(
"
----- version:"
+
version
+
" -----\r\n[gitcode page] => https://gitcode.net/qq_26700087/simpleVideoServer \r\n"
);
AsyncTaskExecutor
asyncTaskExecutor
=
new
AsyncTaskExecutor
();
asyncTaskExecutor
.
start
();
...
...
@@ -56,6 +56,7 @@ public class UDP2Main {
deviceChannel
.
setBufferPool
(
bufferPool
);
deviceChannel
.
setStreamPort
(
getIntProp
(
"stream.port"
,
8004
));
deviceChannel
.
setDispatcherPoolSize
(
getIntProp
(
"udp.video.dispatcher.thread.size"
,
8
));
deviceChannel
.
setFrameDelayTimeout
(
getIntProp
(
"frame.delay.skip.timeout"
,
2000
));
deviceChannel
.
setVideoChannelCount
(
videoChannelCount
);
udpDeviceSnChannelBinder
.
start
();
deviceChannel
.
start
();
...
...
src/org/btik/server/video/device/iface/HttpConstant.java
浏览文件 @
fc529b07
...
...
@@ -8,12 +8,12 @@ public interface HttpConstant {
byte
[]
uri
=
"GET /video"
.
getBytes
(
StandardCharsets
.
UTF_8
);
int
URI_LEN
=
uri
.
length
;
byte
[]
NOT_FOUND
=
(
"
HTTP/1.1 404 \r\n"
+
"Content-Type: text/html; charset=utf-8\r\n"
+
"Content-Length: 12"
+
"\r\n"
+
"\r\n"
+
"<h3>404</h3>
"
).
getBytes
(
StandardCharsets
.
UTF_8
);
byte
[]
NOT_FOUND
=
(
"
""
HTTP/1.1 404 \r
Content-Type: text/html; charset=utf-8\r
Content-Length: 12\r
\r
<h3>404</h3>""
"
).
getBytes
(
StandardCharsets
.
UTF_8
);
String
PART_BOUNDARY
=
"123456789000000000000987654321"
;
String
STREAM_RESP_HEAD
=
"HTTP/1.1 200 OK\r\n"
+
"Content-Type: multipart/x-mixed-replace;boundary="
+
PART_BOUNDARY
+
"\r\n"
+
...
...
src/org/btik/server/video/device/udp2/BufferPool.java
浏览文件 @
fc529b07
...
...
@@ -24,6 +24,10 @@ public class BufferPool {
this
.
bufferPoolSize
=
bufferPoolSize
;
}
public
int
getBufferPoolSize
()
{
return
bufferPoolSize
;
}
private
void
init
()
{
for
(
int
i
=
0
;
i
<
bufferPoolSize
;
i
++)
{
frameBufferPool
.
add
(
new
FrameBuffer
(
new
byte
[
RECEIVE_BUFFER_SIZE
]));
...
...
src/org/btik/server/video/device/udp2/FrameBuffer.java
浏览文件 @
fc529b07
...
...
@@ -2,11 +2,13 @@ package org.btik.server.video.device.udp2;
public
class
FrameBuffer
{
// 2 + 4 + 2字节 2 字节的0 4字节ip 2字节端口
int
channelIndex
=
-
1
;
volatile
int
channelIndex
=
-
1
;
byte
[]
data
;
int
size
;
volatile
int
size
;
volatile
long
time
;
public
FrameBuffer
(
byte
[]
data
)
{
this
.
data
=
data
;
...
...
src/org/btik/server/video/device/udp2/NewUDPDeviceChannel.java
浏览文件 @
fc529b07
...
...
@@ -38,6 +38,11 @@ public class NewUDPDeviceChannel extends Thread implements DevChannel {
private
int
videoChannelCount
=
128
;
/**
* 防止接收图片过快而,浏览器接收过慢,导致帧积压,当帧接收时间到转发时间超过以下延时之后将会被丢弃。
*/
private
long
frameDelayTimeout
=
2000
;
public
void
setStreamPort
(
int
streamPort
)
{
this
.
streamPort
=
streamPort
;
}
...
...
@@ -54,6 +59,10 @@ public class NewUDPDeviceChannel extends Thread implements DevChannel {
this
.
videoChannelCount
=
videoChannelCount
;
}
public
void
setFrameDelayTimeout
(
long
frameDelayTimeout
)
{
this
.
frameDelayTimeout
=
frameDelayTimeout
;
}
/**
* 可选的输入值 1 2 4 8 16 32 64 128 256几个数字,根据cpu核数和设备的数量选择合适的值
* ,输入其它值也会被映射到以上值,如果只有一个摄像头设备那就一个足够,线程数太多而cpu核数过少,
...
...
@@ -83,6 +92,13 @@ public class NewUDPDeviceChannel extends Thread implements DevChannel {
frameDispatchers
[
i
]
=
msgDispatcher
;
executorService
.
submit
(
msgDispatcher
);
}
System
.
out
.
printf
(
"""
dispatcherPoolSize: %d \r
frameDelayTimeout: %d\r
streamPort:[UDP] %d\r
bufferPoolSize:%d\r
"""
,
dispatcherPoolSize
,
frameDelayTimeout
,
streamPort
,
bufferPool
.
getBufferPoolSize
());
System
.
out
.
println
(
"udp channel loaded"
);
super
.
start
();
...
...
@@ -99,7 +115,8 @@ public class NewUDPDeviceChannel extends Thread implements DevChannel {
// 最后一位是通道索引,故长度 -1 才是照片数据
frameBuffer
.
size
=
datagramPacket
.
getLength
()
-
1
;
frameBuffer
.
channelIndex
=
frameBuffer
.
data
[
frameBuffer
.
size
]
&
0xff
;
frameDispatchers
[
frameBuffer
.
channelIndex
&
dispatcherPoolSize
-
1
].
messages
.
add
(
frameBuffer
);
frameBuffer
.
time
=
System
.
currentTimeMillis
();
frameDispatchers
[
frameBuffer
.
channelIndex
&
dispatcherPoolSize
-
1
].
messages
.
add
(
frameBuffer
);
// 切换缓冲区
frameBuffer
=
bufferPool
.
getFrameBuffer
();
datagramPacket
.
setData
(
frameBuffer
.
data
);
...
...
@@ -138,10 +155,20 @@ public class NewUDPDeviceChannel extends Thread implements DevChannel {
try
{
int
channelIndex
=
segment
.
channelIndex
;
if
(
channelIndex
<
0
||
channelIndex
>
videoChannelCount
)
{
System
.
out
.
print
(
"\rThe channel index is illegal "
);
System
.
out
.
print
(
channelIndex
);
continue
;
}
VideoChannel
videoChannel
=
videoChannelTable
[
channelIndex
];
if
(
videoChannel
==
null
)
{
System
.
out
.
print
(
"\rvideoChannel index is not registered and may need to be restarted the ESP ,frame size: "
);
System
.
out
.
print
(
segment
.
size
);
continue
;
}
// 延时跳帧
if
(
System
.
currentTimeMillis
()
>
segment
.
time
+
frameDelayTimeout
)
{
System
.
out
.
print
(
"\rframe time out continue, size : "
);
System
.
out
.
print
(
segment
.
size
);
continue
;
}
videoChannel
.
sendFrame
(
segment
.
data
,
segment
.
size
);
...
...
src/org/btik/server/video/device/udp2/bind/DeviceSnChannelBinder.java
浏览文件 @
fc529b07
...
...
@@ -48,7 +48,7 @@ public class DeviceSnChannelBinder extends Thread {
channelIndexQueue
.
add
(
i
);
}
this
.
port
=
port
;
System
.
out
.
print
ln
(
"sn channel binder started"
);
System
.
out
.
print
f
(
"snChannelBinderPort:[TCP] %d \r\nbinder stared\r\n"
,
port
);
}
...
...
src/org/btik/server/video/device/web/BioHttpVideoServer.java
浏览文件 @
fc529b07
...
...
@@ -20,7 +20,6 @@ import java.util.concurrent.Executors;
/***
* 以http mjpeg 合成视频流对VideoServer的实现
*
* */
public
class
BioHttpVideoServer
extends
Thread
implements
HttpConstant
,
VideoServer
{
private
boolean
runFlag
=
true
;
...
...
@@ -50,6 +49,7 @@ public class BioHttpVideoServer extends Thread implements HttpConstant, VideoSer
@Override
public
synchronized
void
start
()
{
super
.
start
();
System
.
out
.
printf
(
"httpPort:[TCP] %d\n"
,
httpPort
);
System
.
out
.
println
(
"bio video server started"
);
}
...
...
@@ -79,7 +79,7 @@ public class BioHttpVideoServer extends Thread implements HttpConstant, VideoSer
continue
;
}
String
channelStr
=
new
String
(
channel
);
System
.
out
.
println
(
"pre open"
+
new
Date
());
System
.
out
.
println
(
"pre open
"
+
new
Date
());
executorService
.
submit
(()
->
doStreamOpen
(
client
,
channelStr
));
}
catch
(
IOException
e
)
{
disConnect
(
client
,
e
);
...
...
@@ -143,7 +143,7 @@ public class BioHttpVideoServer extends Thread implements HttpConstant, VideoSer
public
VideoChannel
createChannel
(
byte
[]
channelId
)
{
channelId
[
0
]
=
HTTP_PATH_SEPARATOR
;
String
channelIdPath
=
new
String
(
channelId
);
System
.
out
.
println
(
"
new channel:
"
);
System
.
out
.
println
(
"
\r\nChannel "
+
channelIdPath
+
" is online
"
);
printHttpAddress
(
channelIdPath
);
return
videoChannelMap
.
computeIfAbsent
(
channelIdPath
,
channelIdStr
->
new
MJPEGVideoChannel
(
channelIdStr
,
asyncTaskExecutor
));
...
...
src/org/btik/server/video/device/web/MJPEGVideoChannel.java
浏览文件 @
fc529b07
...
...
@@ -7,12 +7,13 @@ import org.btik.server.video.device.iface.VideoChannel;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.net.
Socket
;
import
java.net.
*
;
import
java.util.Collections
;
import
java.util.Date
;
import
java.util.Set
;
import
java.util.concurrent.ConcurrentHashMap
;
/**
* 视频频道
* 在线的摄像头均有一个频道
...
...
@@ -24,7 +25,7 @@ public class MJPEGVideoChannel implements VideoChannel, HttpConstant {
/**
* 暂时没有用,debug时可以分辨属于哪个设备
*/
private
String
channelId
;
private
final
String
channelId
;
private
final
Set
<
Socket
>
clients
=
Collections
.
newSetFromMap
(
new
ConcurrentHashMap
<>());
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录