Browse Source

Merge branch 'dev' of linzhuo/patient-co-management into dev

lyr 8 years ago
parent
commit
d219025e16

+ 4 - 2
patient-co-wlyy/src/main/java/com/yihu/wlyy/util/CommonUtil.java

@ -272,10 +272,12 @@ public class CommonUtil {
        }
    }
    public static String getVideoTimeAndImg(String sourcePath,String targetPath) throws  Exception{
    public static long getVideoTimeAndImg(String sourcePath,String targetPath) throws  Exception{
        File source = new File(sourcePath);
        Encoder encoder = new Encoder();
        MultimediaInfo m = encoder.getInfo(source);
        long ms = m.getDuration();
        if(ms<1000)return ms;
        File target = new File(targetPath);//转图片
        VideoAttributes video = new VideoAttributes();
        video.setCodec("png");//转图片
@ -286,7 +288,7 @@ public class CommonUtil {
        attrs.setDuration(0.01f);//设置转码持续时间(1秒)
        attrs.setVideoAttributes(video);
        encoder.encode(source, target, attrs);
        return m.getDuration()+"";
        return m.getDuration();
    }

+ 12 - 4
patient-co-wlyy/src/main/java/com/yihu/wlyy/web/common/FileUploadController.java

@ -197,7 +197,15 @@ public class FileUploadController extends BaseController {
                    String pngPath = tempPath.substring(0,tempPath.lastIndexOf("."))+".png";
                    File tempFile = new File(tempPath);
                    File pngFile = new File(pngPath);
                    String times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
                    long times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
                    if(times<1000){
                        JSONObject json = new JSONObject();
                        json.put("status", -1);
                        json.put("success",true);
                        json.put("msg", "视频录制时间太短!");
                        json.put("times", times);
                        return json.toString();
                    }
                    ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath),"png","");
                    String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
                    ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath),fileExt,"");
@ -205,7 +213,7 @@ public class FileUploadController extends BaseController {
                            + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"",""));
                    tempPaths.add(fastUrl + videoNode.get("groupName").toString().replaceAll("\"","")
                            + "/" + videoNode.get("remoteFileName").toString().replaceAll("\"",""));
                    tempPaths.add(times);
                    tempPaths.add(times+"");
                    if(tempFile!=null){
                        tempFile.delete();
                    }
@ -325,7 +333,7 @@ public class FileUploadController extends BaseController {
            String pngPath = tempPath.substring(0,tempPath.lastIndexOf("."))+".png";
            File tempFile = new File(tempPath);
            File pngFile = new File(pngPath);
            String times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
            long times = CommonUtil.getVideoTimeAndImg(tempPath,pngPath);
            ObjectNode imgNode = fastDFSUtil.upload(new FileInputStream(pngPath),"png","");
            String fileExt = fileName.substring(fileName.lastIndexOf(".") + 1).toLowerCase();
            ObjectNode videoNode = fastDFSUtil.upload(new FileInputStream(tempPath),fileExt,"");
@ -333,7 +341,7 @@ public class FileUploadController extends BaseController {
                    + "/" + imgNode.get("remoteFileName").toString().replaceAll("\"",""));
            tempPaths.add(fastUrl + videoNode.get("groupName").toString().replaceAll("\"","")
                    + "/" + videoNode.get("remoteFileName").toString().replaceAll("\"",""));
            tempPaths.add(times);
            tempPaths.add(times+"");
            if(tempFile!=null){
                tempFile.delete();
            }