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