shell,java,php代码如何批量计算音频文件的总时长?
1个回答
展开全部
File file = new File("G:\\8.mp3");
long total = 0;
try {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
Map props = aff.properties();
if (props.containsKey("duration"))
total = (long) Math.round((((Long) props.get("duration"))
.longValue())/1000);
System.out.println(total);
} catch (UnsupportedAudioFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
long total = 0;
try {
AudioFileFormat aff = AudioSystem.getAudioFileFormat(file);
Map props = aff.properties();
if (props.containsKey("duration"))
total = (long) Math.round((((Long) props.get("duration"))
.longValue())/1000);
System.out.println(total);
} catch (UnsupportedAudioFileException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询