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

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();//输出参数
FileUtils.deleteFile(srcFileAllPath); JSONArray resArray =JSONArray.fromObject(out);
map.put("status", 1); JSONObject resObject = resArray.getJSONObject(0);
map.put("msg", "success"); logger.info("调用视频转关键帧图片程序输出参数:"+resObject);
int state = resObject.getInt("state");
if(state==1){
//关键帧图片生成成功,删除原视频文件
FileUtils.deleteFile(srcFileAllPath);
map.put("status", 1);
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,47 +47,50 @@ $(function(){
}); });
$("#srcFile").on('change',function(){ $("#srcFile").on('change',function(){
sampleFileValidate(fileType,$("#srcFile").val()); if(sampleFileValidate(fileType,$("#srcFile").val())){
$("#srcFileInfo").val($("#srcFile").val()); //样例文件类型正确进行后续处理
var videoToPicture = $("#videoToPicture").val(); $("#srcFileInfo").val($("#srcFile").val());
if(videoToPicture=="true"){ var videoToPicture = $("#videoToPicture").val();
if(videoToPicture=="true"){
var fd = new FormData($('#cfgFrom')[0]);
$.ajax({ var fd = new FormData($('#cfgFrom')[0]);
url: "${ctx}/ntc/av/sample/videoToPicture", $.ajax({
type: "POST", url: "${ctx}/ntc/av/sample/videoToPicture",
processData: false, type: "POST",
contentType: false, processData: false,
data: fd, contentType: false,
async: true, data: fd,
cache: false, async: true,
beforeSend: function(){ cache: false,
loading('onloading...'); beforeSend: function(){
}, loading('onloading...');
success: function(data) { },
top.$.jBox.closeTip(); success: function(data) {
if(data.status==1){ top.$.jBox.closeTip();
$("#picPath").val(data.picFilePath); if(data.status==1){
$("#showPicture").removeClass("hidden"); $("#picPath").val(data.picFilePath);
var url = "${ctx}/ntc/av/sample/selectVedioPicture?picFilePath="+encodeURIComponent(data.picFilePath); $("#showPicture").removeClass("hidden");
$.jBox("iframe:"+url, { var url = "${ctx}/ntc/av/sample/selectVedioPicture?picFilePath="+encodeURIComponent(data.picFilePath);
title: "", $.jBox("iframe:"+url, {
width: 1350, title: "",
height:800, top: '1%',
dragLimit: true, draggable:false,
buttons: { 'close': true,"ok":"ok" } width: 1000,
}); height:500,
}else{ buttons: { 'close': true }
alert(data.msg); });
} }else{
alert(data.msg);
}, }
error:function(jqXHR, textStatus, errorThrown){
top.$.jBox.closeTip(); },
alert(errorThrown); error:function(jqXHR, textStatus, errorThrown){
return false; top.$.jBox.closeTip();
} alert(errorThrown);
}); return false;
}
});
}
} }
}); });
/* $("#uploadSample,#sampleFileInfo").on('click',function(){ /* $("#uploadSample,#sampleFileInfo").on('click',function(){