public void ReadVideoTime(String path) { long sum = 0; long num = 0; File source = new File(path[i]); Encoder encoder = new Encoder(); File[] file = source.listFiles(); for (File file2 : file) { try { MultimediaInfo m = encoder.getInfo(file2); long ls = m.getDuration() / 1000;// ls是获取到的秒数 sum += ls; num++; } catch (Exception e) { e.printStackTrace(); } } double sum1 = (double) sum; double sum2 = sum1 / 3600;// 转换成为了小时 System.out.println(sum2); System.out.println(num); }