调整 录制时长 和 超时控制
This commit is contained in:
parent
c4ebda0713
commit
0bcebc8c30
@ -33,19 +33,19 @@ public class RecordService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void record(HttpServletRequest request, HttpServletResponse response, String url, long timeout) {
|
public void record(HttpServletRequest request, HttpServletResponse response, String url, long time) {
|
||||||
AsyncContext asyncContext = request.startAsync();
|
AsyncContext asyncContext = request.startAsync();
|
||||||
asyncContext.setTimeout(0);
|
asyncContext.setTimeout(0);
|
||||||
asyncContext.start(() -> {
|
asyncContext.start(() -> {
|
||||||
header(response);
|
header(response);
|
||||||
record(asyncContext.getResponse(), url, timeout);
|
record(asyncContext.getResponse(), url, time, 60);
|
||||||
log.info("record 结束");
|
log.info("record 结束");
|
||||||
asyncContext.complete();
|
asyncContext.complete();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
public void record(ServletResponse response, String url, long timeout) {
|
public void record(ServletResponse response, String url, long time ,long timeout) {
|
||||||
// response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
// response.setContentType(MediaType.APPLICATION_OCTET_STREAM_VALUE);
|
||||||
Path tmp = Path.of(System.getProperty("java.io.tmpdir"), IdUtil.getSnowflakeNextIdStr()).toAbsolutePath();
|
Path tmp = Path.of(System.getProperty("java.io.tmpdir"), IdUtil.getSnowflakeNextIdStr()).toAbsolutePath();
|
||||||
File file = new File(tmp + ".mp4");
|
File file = new File(tmp + ".mp4");
|
||||||
@ -69,8 +69,8 @@ public class RecordService {
|
|||||||
scheduledExecutorService.schedule(() -> {
|
scheduledExecutorService.schedule(() -> {
|
||||||
log.info("到达超时时间, 结束录制");
|
log.info("到达超时时间, 结束录制");
|
||||||
record.set(false);
|
record.set(false);
|
||||||
}, timeout + 60, TimeUnit.SECONDS);
|
}, time + timeout, TimeUnit.SECONDS);
|
||||||
long maxTime = TimeUnit.SECONDS.toMicros(timeout);
|
long maxTime = TimeUnit.SECONDS.toMicros(time);
|
||||||
try {
|
try {
|
||||||
Frame frame;
|
Frame frame;
|
||||||
while (!recorder.isCloseOutputStream() && record.get() && (frame = grabber.grab()) != null) {
|
while (!recorder.isCloseOutputStream() && record.get() && (frame = grabber.grab()) != null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user