java得到视频时间

来源:互联网 发布:linux用办公软件 编辑:程序博客网 时间:2024/06/07 03:38
</pre><pre code_snippet_id="1597128" snippet_file_name="blog_20160304_1_5079587" name="code" class="java">//获取视频的时长            jave 下载:http://www.sauronsoftware.it/projecty/java/index.phpEncoder encoder = new Encoder();        try {             MultimediaInfo m = encoder.getInfo(file);             long l = m.getDuration()/1000;//计算奔视频有多少秒             long hour = l/3600;//计算有多少个小时             long min = (l - hour*3600)/60;//计算有多少分钟             long sec = l % 60;//计算有多少秒                          String h1 = ""+hour;             String m1 = ""+min;             String s1 = ""+sec;             if(hour < 10){h1 = "0" + hour;}             if(min < 10){m1 = "0" + min;}             if(sec < 10){s1 = "0" + sec;}             String normalTime = h1 + ":" + m1 + ":" + s1;             System.out.println(normalTime);        } catch (Exception e) {            e.printStackTrace();        }

1 0
原创粉丝点击