Java获取3gp视频时长,其他格式的好像也可以,没有全部去试
/**
* 获取视频的时间长
*/
public static String getVideoTime(String destFile) {
String timeStr = null;
File source = new File(destFile);
if (source.exists()) {
try {
Encoder encoder = new Encoder();
MultimediaInfo mInfo = encoder.getInfo(source);
long timeLen = mInfo.getDuration();
timeStr = timeLen/1000 + "s";
} catch (InputFormatException e) {
e.printStackTrace();
} catch (EncoderException e) {
e.printStackTrace();
}
}
return timeStr;
}