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;
}
本文介绍了一种使用Java代码获取3gp格式视频时长的方法,并提供了完整的代码示例。该方法同样适用于其他视频格式。
388

被折叠的 条评论
为什么被折叠?



