新增根据 指定时间范围的 recordInfo 查询, 预下载视频文件到本地指定路径
This commit is contained in:
parent
92fb1555fd
commit
70019451d2
@ -75,6 +75,11 @@ public class VideoCacheManager {
|
|||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
protected CompletableFuture<JsonResponse<String>> downloadVideo(String deviceCode, Date startTime, Date endTime) {
|
protected CompletableFuture<JsonResponse<String>> downloadVideo(String deviceCode, Date startTime, Date endTime) {
|
||||||
return CompletableFuture.supplyAsync(()->{
|
return CompletableFuture.supplyAsync(()->{
|
||||||
|
File realFile = Paths.get(deviceProxyConfig.getPreDownloadForRecordInfo().getCachePath(),fileName(deviceCode, startTime, endTime) + ".mp4").toFile();
|
||||||
|
if(realFile.exists()){
|
||||||
|
return JsonResponse.success(realFile.getAbsolutePath());
|
||||||
|
}
|
||||||
|
|
||||||
final String url = UrlBuilder.of(deviceProxyConfig.getUrl())
|
final String url = UrlBuilder.of(deviceProxyConfig.getUrl())
|
||||||
.addPath("video")
|
.addPath("video")
|
||||||
.addQuery("device_id", deviceCode)
|
.addQuery("device_id", deviceCode)
|
||||||
@ -103,7 +108,6 @@ public class VideoCacheManager {
|
|||||||
});
|
});
|
||||||
log.info("视频下载完成 => {}", file.getAbsolutePath());
|
log.info("视频下载完成 => {}", file.getAbsolutePath());
|
||||||
log.info("文件 {}, 是否存在: {}", file.getAbsolutePath(), file.exists());
|
log.info("文件 {}, 是否存在: {}", file.getAbsolutePath(), file.exists());
|
||||||
File realFile = Paths.get(deviceProxyConfig.getPreDownloadForRecordInfo().getCachePath(),fileName(deviceCode, startTime, endTime) + ".mp4").toFile();
|
|
||||||
file.renameTo(realFile);
|
file.renameTo(realFile);
|
||||||
lock.release();
|
lock.release();
|
||||||
return JsonResponse.success(realFile.getAbsolutePath());
|
return JsonResponse.success(realFile.getAbsolutePath());
|
||||||
|
Loading…
Reference in New Issue
Block a user