异常处理

This commit is contained in:
shikong 2024-03-15 11:09:03 +08:00
parent 054ab25205
commit 04cfcfd22a

View File

@ -270,13 +270,19 @@ public class VideoService {
if(ffmpegConfig.getUseTmpFile()) { if(ffmpegConfig.getUseTmpFile()) {
ServletOutputStream servletOutputStream = response.getOutputStream(); ServletOutputStream servletOutputStream = response.getOutputStream();
try{
log.info("临时文件 {}(大小 {})", file.getAbsolutePath(), file.length());
IoUtil.copy(new FileInputStream(file), servletOutputStream); IoUtil.copy(new FileInputStream(file), servletOutputStream);
response.flushBuffer(); response.flushBuffer();
} catch (Exception e){
log.error("写入 http 响应异常: {}", e.getMessage());
} finally {
System.gc(); System.gc();
boolean delete = file.delete(); boolean delete = file.delete();
log.info("删除临时文件 {} => {}", file, delete); log.info("删除临时文件 {} => {}", file, delete);
} }
} }
}
/** /**
* 录制视频 并写入 异步响应 * 录制视频 并写入 异步响应