视频样式转关键帧图片过程增加返回参数验证。

This commit is contained in:
zhangwei
2018-10-25 17:29:49 +08:00
parent 77446728ea
commit f2d013ec70
2 changed files with 71 additions and 45 deletions

View File

@@ -15,6 +15,9 @@ import java.util.UUID;
import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.io.filefilter.IOFileFilter; import org.apache.commons.io.filefilter.IOFileFilter;
import org.apache.tools.zip.ZipOutputStream; import org.apache.tools.zip.ZipOutputStream;
import org.springframework.mock.web.MockMultipartFile; import org.springframework.mock.web.MockMultipartFile;
@@ -557,12 +560,32 @@ public class AvController extends BaseController {
String shellName = Constants.VEDIO_TO_PICTURE_PROC; String shellName = Constants.VEDIO_TO_PICTURE_PROC;
// String params = srcFileAllPath+" "+picFilePath+" 0.95 90.0 0.5"; // String params = srcFileAllPath+" "+picFilePath+" 0.95 90.0 0.5";
String params = srcFileAllPath+" "+picFilePath; String params = srcFileAllPath+" "+picFilePath;
logger.info("调用视频转关键帧图片程序输入参数:"+params);
Map resultMap = avCfgService.execShell(shellName, params); Map resultMap = avCfgService.execShell(shellName, params);
if(resultMap.get("exitStatus").equals(0)){//调用外部程序成功 if(resultMap.get("exitStatus").equals(0)){//调用外部程序成功
String out = resultMap.get("out").toString();//输出参数
JSONArray resArray =JSONArray.fromObject(out);
JSONObject resObject = resArray.getJSONObject(0);
logger.info("调用视频转关键帧图片程序输出参数:"+resObject);
int state = resObject.getInt("state");
if(state==1){
//关键帧图片生成成功,删除原视频文件 //关键帧图片生成成功,删除原视频文件
FileUtils.deleteFile(srcFileAllPath); FileUtils.deleteFile(srcFileAllPath);
map.put("status", 1); map.put("status", 1);
map.put("msg", "success"); map.put("msg", "success");
}else{
if(StringUtil.isEmpty(resObject.getString("message"))){
map.put("status", 0);
map.put("msg", getMsgProp().getProperty("call_external_procedures_failed", "Call external procedures failed"));
}else{
map.put("status", 0);
map.put("msg", resObject.getString("message"));
}
}
}else{
map.put("status", 0);
map.put("msg", getMsgProp().getProperty("call_external_procedures_failed", "Call external procedures failed"));
} }
}else{ }else{
map.put("status", 0); map.put("status", 0);

View File

@@ -47,7 +47,8 @@ $(function(){
}); });
$("#srcFile").on('change',function(){ $("#srcFile").on('change',function(){
sampleFileValidate(fileType,$("#srcFile").val()); if(sampleFileValidate(fileType,$("#srcFile").val())){
//样例文件类型正确进行后续处理
$("#srcFileInfo").val($("#srcFile").val()); $("#srcFileInfo").val($("#srcFile").val());
var videoToPicture = $("#videoToPicture").val(); var videoToPicture = $("#videoToPicture").val();
if(videoToPicture=="true"){ if(videoToPicture=="true"){
@@ -72,10 +73,11 @@ $(function(){
var url = "${ctx}/ntc/av/sample/selectVedioPicture?picFilePath="+encodeURIComponent(data.picFilePath); var url = "${ctx}/ntc/av/sample/selectVedioPicture?picFilePath="+encodeURIComponent(data.picFilePath);
$.jBox("iframe:"+url, { $.jBox("iframe:"+url, {
title: "", title: "",
width: 1350, top: '1%',
height:800, draggable:false,
dragLimit: true, width: 1000,
buttons: { 'close': true,"ok":"ok" } height:500,
buttons: { 'close': true }
}); });
}else{ }else{
alert(data.msg); alert(data.msg);
@@ -89,6 +91,7 @@ $(function(){
} }
}); });
} }
}
}); });
/* $("#uploadSample,#sampleFileInfo").on('click',function(){ /* $("#uploadSample,#sampleFileInfo").on('click',function(){
$("#sampleFile").trigger("click"); $("#sampleFile").trigger("click");