Commit 7529f223eb249f4fe6976eb183eab80d1459662d

Authored by 郑超
1 parent a3f8d16b

视频时长小于60秒的 抽帧时传入num字段

src/main/java/com/cnlive/shenhe/api/AvsampleCallBackControllerApi.java
... ... @@ -29,43 +29,51 @@ public class AvsampleCallBackControllerApi {
29 29  
30 30 /**
31 31 * 接收抽帧结果
  32 + *
32 33 * @param json
33 34 */
34 35 @PostMapping("/callback")
35 36 @ResponseBody
36 37 public JSONObject callback(@RequestBody JSONObject json) {
37   - logger.info("抽帧回调请求。。。。json=="+json.toJSONString());
38 38 JSONObject result = new JSONObject();
39   - result.put("code",1);
40   - String taskId = json.getString("taskId");
41   - if(CommonUtils.isNotEmpty(taskId)){
42   - ShyVideos shyVideo = new ShyVideos();
43   - shyVideo.setTask_id(taskId);
44   - List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideo);
45   - if(!shyVideosList.isEmpty()){
46   - ShyVideos video = shyVideosList.get(0);
47   - Integer code = json.getInteger("code");
48   - if(code==3){
49   - video.setAvsample(CommonConst.AVSAMPLE_SUCCESS);
50   - video.setAvsample_imgs(json.getJSONArray("images").toJSONString());
51   - }else{
52   - video.setAvsample(CommonConst.AVSAMPLE_FAIL);//抽帧失败
53   - video.setShenhe_type(CommonConst.AUDIT_TYPE_USER);//改为人工审核
54   - video.setMsg("抽帧失败,改为人工审核,失败消息:"+json.getInteger("errorMsg"));
55   - }
56   - video.setAvsample_msg(json.toJSONString());
57   - boolean success = videosService.updateshyVideos(video);
58   - if(!success){
59   - result.put("code",-1);
  39 + result.put("code", 1);
  40 + try {
  41 + logger.info("抽帧回调请求。。。。json=={}", json.toJSONString());
  42 + String taskId = json.getString("taskId");
  43 + if (CommonUtils.isNotEmpty(taskId)) {
  44 + ShyVideos shyVideo = new ShyVideos();
  45 + shyVideo.setTask_id(taskId);
  46 + List<ShyVideos> shyVideosList = videosService.findshyVideo(shyVideo);
  47 + if (!shyVideosList.isEmpty()) {
  48 + ShyVideos video = shyVideosList.get(0);
  49 + Integer code = json.getInteger("code");
  50 + if (code == 3) {
  51 + video.setAvsample(CommonConst.AVSAMPLE_SUCCESS);
  52 + video.setAvsample_imgs(json.getJSONArray("images").toJSONString());
  53 + } else {
  54 + //抽帧失败
  55 + video.setAvsample(CommonConst.AVSAMPLE_FAIL);
  56 + //改为人工审核
  57 + video.setShenhe_type(CommonConst.AUDIT_TYPE_USER);
  58 + video.setMsg("抽帧失败,改为人工审核,失败消息:" + json.getString("errorMsg"));
  59 + }
  60 + video.setAvsample_msg(json.toJSONString());
  61 + boolean success = videosService.updateshyVideos(video);
  62 + if (!success) {
  63 + result.put("code", -1);
  64 + }
60 65 }
61 66 }
  67 + return result;
  68 + } catch (Exception e) {
  69 + e.printStackTrace();
62 70 }
63 71 return result;
64 72 }
65   -
  73 +
66 74 @GetMapping("/getGame")
67   - public String getGame(){
68   - return "html/game.html";
  75 + public String getGame() {
  76 + return "html/game.html";
69 77 }
70   -
  78 +
71 79 }
... ...
src/main/java/com/cnlive/shenhe/api/VideosControllerApi.java
... ... @@ -223,13 +223,16 @@ public class VideosControllerApi {
223 223  
224 224 //非“目击者”视频
225 225 if (!video.getCategory().equals(CommonConst.CATEGORY_WITNESS)) {
226   - //默认抽帧时长
227   - Integer interval = 10;
228   - //抽帧时长的算法:视频时长每增加一小时,抽帧时长增加10秒
229   - interval = video.getDuration() / 3600 * 10 + 10;
  226 + //默认抽帧时长 抽帧时长的算法:视频时长每增加一小时,抽帧时长增加10秒
  227 + Integer duration = video.getDuration();
  228 + Integer interval = duration / 3600 * 10 + 10;
230 229 attach.put("interval", interval);
231 230 attach.put("strategy", 1);
232 231 attach.put("duration", video.getDuration());
  232 + if (duration < 60) {
  233 + int num = duration / 10;
  234 + attach.put("num", num == 0 ? 1 : num);
  235 + }
233 236 } else {
234 237 //“目击者”视频时间大于4秒
235 238 if (video.getDuration() > 4) {
... ... @@ -295,4 +298,5 @@ public class VideosControllerApi {
295 298 return video;
296 299 }
297 300  
  301 +
298 302 }
... ...