File source = new File("视频.mp4");Encoder encoder = new Encoder();try { MultimediaInfo info = encoder.getInfo(source); System.out.println("dura="+info.getDuration()); Date date = new Date(info.getDuration()); SimpleDateFormat sdf = new SimpleDateFormat("HH:mm:ss",Locale.getDefault()); sdf.setTimeZone(TimeZone.getTimeZone("GMT")); System.out.println("时长="+sdf.format(date));} catch (Exception e) { }
引入jar包下载地址