将MultipartFile转换为file与java获取视频时长

		 //MultipartFile转为file
        File f = null;

        try {

            f = File.createTempFile("tmp", suffix);
            file.transferTo(f);

            f.deleteOnExit();

            //获取视频时长
            MultimediaObject instance = new MultimediaObject(f);
            MultimediaInfo result = instance.getInfo();

            long ls = result.getDuration() / 1000;

            System.out.println("ls = " + ls);
        } catch (Exception e) {
            e.printStackTrace();
        }

相关包的maven依赖


    ws.schild
    jave-all-deps
    2.4.0

gradle依赖

compile "ws.schild:jave-all-deps:2.4.0"

你可能感兴趣的:(java-web)