[*] 修复通道删除

This commit is contained in:
acgist
2023-06-02 09:20:40 +08:00
parent becc68b05f
commit d49444ba60
9 changed files with 96 additions and 74 deletions

View File

@@ -31,6 +31,10 @@ public class FfmpegProperties {
private String storageImagePath;
@Schema(title = "视频存储目录", description = "视频存储目录")
private String storageVideoPath;
@Schema(title = "预览截图时间", description = "预览截图时间")
private Integer previewTime;
@Schema(title = "预览截图时间", description = "预览截图时间")
private String durationRegex;
@Schema(title = "录像录像地址", description = "录像录像地址")
private String host;
@Schema(title = "录像最小端口", description = "录像最小端口")

View File

@@ -235,13 +235,12 @@ taoyao:
c=IN IP4 127.0.0.1
a=rtpmap:100 OPUS/48000/2
a=fmtp:100 sprop-stereo=1
m=video %d RTP/AVP 107
m=video %d RTP/AVP 101
c=IN IP4 127.0.0.1
a=rtpmap:107 H264/90000
a=fmtp:107 packetization-mode=1
a=rtpmap:101 VP8/90000
# 录像命令
record: ffmpeg -protocol_whitelist "file,rtp,udp" -y -i %s %s
# 截图命令
# 预览命令
preview: ffmpeg -y -i %s -ss %d -vframes 1 -f image2 %s
# 时长命令
duration: ffprobe -i %s -show_entries format=duration
@@ -251,6 +250,10 @@ taoyao:
storage-image-path: /data/taoyao/storage/image
# 视频存储目录
storage-video-path: /data/taoyao/storage/video
# 预览时间
preview-time: 4
# 时长提取
duration-regex: .*duration\=([0-9\.]+).*
# 录像地址
#host: 127.0.0.1
host: 192.168.8.40

View File

@@ -16,29 +16,28 @@ public class RecorderTest {
ffmpegProperties.setHost("127.0.0.1");
ffmpegProperties.setSdp("""
v=0
o=- 0 0 IN IP4 %s
o=- 0 0 IN IP4 127.0.0.1
s=TaoyaoRecord
t=0 0
m=audio %d RTP/AVP 97
c=IN IP4 %s
c=IN IP4 127.0.0.1
a=rtpmap:97 OPUS/48000/2
a=fmtp:97 sprop-stereo=1
m=video %d RTP/AVP 96
c=IN IP4 %s
c=IN IP4 127.0.0.1
a=rtpmap:96 VP8/90000
a=fmtp:96 packetization-mode=1
""");
// ffmpegProperties.setSdp("""
// v=0
// o=- 0 0 IN IP4 %s
// o=- 0 0 IN IP4 127.0.0.1
// s=TaoyaoRecord
// t=0 0
// m=audio %d RTP/AVP 97
// c=IN IP4 %s
// c=IN IP4 127.0.0.1
// a=rtpmap:97 OPUS/48000/2
// a=fmtp:97 sprop-stereo=1
// m=video %d RTP/AVP 96
// c=IN IP4 %s
// c=IN IP4 127.0.0.1
// a=rtpmap:96 H264/90000
// a=fmtp:96 packetization-mode=1
// """);

View File

@@ -159,6 +159,7 @@ public class Recorder {
this.thread.setDaemon(true);
this.thread.setName("TaoyaoRecord");
this.thread.start();
log.info("开始录像:{}", this.folder);
}
/**
@@ -210,14 +211,14 @@ public class Recorder {
* 视频预览截图
*/
private void preview() {
int time = 2;
int time = this.ffmpegProperties.getPreviewTime();
final File file = Paths.get(this.preview).toFile();
while(time > 0 && !(file.exists() && file.length() > 0L)) {
log.debug("视频预览截图{}", this.preview);
do {
log.debug("视频预览:{}", this.preview);
final String previewScript = String.format(this.ffmpegProperties.getPreview(), this.filepath, time, this.preview);
ScriptUtils.execute(previewScript);
time /= 2;
}
} while (time > 0 && !(file.exists() && file.length() > 0L));
}
/**
@@ -227,7 +228,7 @@ public class Recorder {
log.debug("视频时长:{}", this.filepath);
final String durationScript = String.format(this.ffmpegProperties.getDuration(), this.filepath);
final ScriptExecutor executor = ScriptUtils.execute(durationScript);
final Pattern pattern = Pattern.compile(".*duration\\=([0-9\\.]+).*");
final Pattern pattern = Pattern.compile(this.ffmpegProperties.getDurationRegex());
final Matcher matcher = pattern.matcher(executor.getResult());
String duration = null;
if(matcher.find()) {

View File

@@ -148,6 +148,7 @@ public class ControlServerRecordProtocol extends ProtocolControlAdapter implemen
message.setBody(body);
final Client mediaClient = room.getMediaClient();
mediaClient.request(message);
// TODO回写ID格式自动判断
return recorder.getFilepath();
}