- 浏览: 543545 次
- 性别:
- 来自: 北京
文章分类
- 全部博客 (618)
- java (109)
- Java web (43)
- javascript (52)
- js (15)
- 闭包 (2)
- maven (8)
- 杂 (28)
- python (47)
- linux (51)
- git (18)
- (1)
- mysql (31)
- 管理 (1)
- redis (6)
- 操作系统 (12)
- 网络 (13)
- mongo (1)
- nginx (17)
- web (8)
- ffmpeg (1)
- python安装包 (0)
- php (49)
- imagemagic (1)
- eclipse (21)
- django (4)
- 学习 (1)
- 书籍 (1)
- uml (3)
- emacs (19)
- svn (2)
- netty (9)
- joomla (1)
- css (1)
- 推送 (2)
- android (6)
- memcached (2)
- docker、 (0)
- docker (7)
- go (1)
- resin (1)
- groovy (1)
- spring (1)
最新评论
-
chokee:
...
Spring3 MVC 深入研究 -
googleyufei:
很有用, 我现在打算学学Python. 这些资料的很及时.
python的几个实用网站(转的) -
hujingwei1001:
太好了找的就是它
easy explore -
xiangtui:
例子举得不错。。。学习了
java callback -
幻影桃花源:
太好了,謝謝
Spring3 MVC 深入研究
来源地址:http://bbs.csdn.net/topics/340267510
/**
* 获取视频播放总时长
*
* @param fileName
* 视频名称
* @param dir
* 存放视频的目录
* @return
* @throws IOException
*/
public static long getVideoPlayTime(String videoName, File dir) throws IOException{
Process p = null;
if (isWindowsSystem()) {
p = Runtime.getRuntime().exec(
"cmd /c timelength.bat " + "\"" + dir.getPath() + "/" + videoName
+ ".wmv\"");
} else {
String cmd = "sh " + getMplayerBinPath() + "/timelength.sh " + dir.getPath()+ "/" + videoName + ".wmv";
p = Runtime.getRuntime().exec(cmd);
}
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
if(line != null){
if(line.startsWith("ID_LENGTH")){
String second = line.split("=")[1].trim();
int pos = 0;
if((pos = second.indexOf(".")) != -1){
// 去除小数点后的数字
return Long.parseLong(second.substring(0, pos));
}else{
return Long.parseLong(second);
}
}
}
}
try {
br.close();
isr.close();
is.close();
} catch (Exception e) {
}
return 0;
}
/**
* 格式化视频播放时长
* @param time
* @return
*/
public static String formatVideoTimeLength(long time) {
long s = time % 60;
long m = (time / 60) % 60;
long h = time / 3600;
return toTimeString(h) + ":" + toTimeString(m) + ":" + toTimeString(s);
}
获取音频时长
import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
public class AudioLength {
public static void main(String[] args) throws LineUnavailableException,
UnsupportedAudioFileException, IOException {
File file = new File("d:/test.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(file);
clip.open(ais);
System.out.println( clip.getMicrosecondLength() / 1000000D + " s" );
}
}
/**
* 获取视频播放总时长
*
* @param fileName
* 视频名称
* @param dir
* 存放视频的目录
* @return
* @throws IOException
*/
public static long getVideoPlayTime(String videoName, File dir) throws IOException{
Process p = null;
if (isWindowsSystem()) {
p = Runtime.getRuntime().exec(
"cmd /c timelength.bat " + "\"" + dir.getPath() + "/" + videoName
+ ".wmv\"");
} else {
String cmd = "sh " + getMplayerBinPath() + "/timelength.sh " + dir.getPath()+ "/" + videoName + ".wmv";
p = Runtime.getRuntime().exec(cmd);
}
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line = null;
while ((line = br.readLine()) != null) {
if(line != null){
if(line.startsWith("ID_LENGTH")){
String second = line.split("=")[1].trim();
int pos = 0;
if((pos = second.indexOf(".")) != -1){
// 去除小数点后的数字
return Long.parseLong(second.substring(0, pos));
}else{
return Long.parseLong(second);
}
}
}
}
try {
br.close();
isr.close();
is.close();
} catch (Exception e) {
}
return 0;
}
/**
* 格式化视频播放时长
* @param time
* @return
*/
public static String formatVideoTimeLength(long time) {
long s = time % 60;
long m = (time / 60) % 60;
long h = time / 3600;
return toTimeString(h) + ":" + toTimeString(m) + ":" + toTimeString(s);
}
获取音频时长
import java.io.File;
import java.io.IOException;
import javax.sound.sampled.AudioInputStream;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Clip;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.UnsupportedAudioFileException;
public class AudioLength {
public static void main(String[] args) throws LineUnavailableException,
UnsupportedAudioFileException, IOException {
File file = new File("d:/test.wav");
Clip clip = AudioSystem.getClip();
AudioInputStream ais = AudioSystem.getAudioInputStream(file);
clip.open(ais);
System.out.println( clip.getMicrosecondLength() / 1000000D + " s" );
}
}
发表评论
-
java的InputStream和OutputStream的理解【转】
2015-11-09 18:10 621原文地址:http://www.cnblogs.com/spr ... -
【JSP】让HTML和JSP页面不缓存的方法
2015-10-14 10:16 444原文地址:http://blog.csdn.net/juebl ... -
jsp去掉浏览器缓存
2015-10-14 09:21 588原文地址:http://bbs.csdn.net/topics ... -
Spring定时任务的几种实现
2015-09-17 18:02 358原文地址:http://gong1208.iteye.com/ ... -
Java 8 简明教程
2015-08-31 17:43 322原文地址:http://www.iteye.com/magaz ... -
Java 8 简明教程
2015-08-28 15:30 536原文地址:http://www.iteye.com/magaz ... -
Spring 3.0 注解注入详解
2015-08-20 12:01 485原文地址:http://developer.51cto.com ... -
Apache所有项目介绍
2015-08-20 11:47 916原文地址:http://haisha.iteye.com/bl ... -
jdk5.0新特性介绍
2015-08-04 18:08 443原文地址:http://blog.sina.com.cn/s/ ... -
Apache Log4j配置说明
2015-05-18 15:59 386原文地址:http://zhangjunh ... -
ubuntu 14.04 下通过apt-get 安装jdk
2015-04-09 16:42 659原文地址:http://segmentfault.com/a/ ... -
【原创】Eclipse Class Decompiler——Java反编译插件
2015-04-01 15:00 571原文地址:http://www.blogj ... -
jvisualvm远程监控Tomcat
2015-03-06 10:19 678原文地址:http://ihuangweiwei.iteye. ... -
Java 并发核心编程
2015-01-08 18:07 589原文地址:http://www.cnblogs.com/see ... -
log4j日志文件乱码问题的解决方法
2015-01-06 18:11 786原文地址:http://blog.csdn.net/inkfi ... -
SHA1与MD5
2014-12-22 15:31 572原文地址:http://blog.csdn.net/fogle ... -
征服 Redis + Jedis
2014-12-19 13:51 370原文地址:http://snowolf.iteye.com/b ... -
Java连接redis的使用示例
2014-12-19 12:08 1033原文地址:http://blog.csdn.net/wgw33 ... -
java对redis的基本操作
2014-12-19 12:07 553原文地址:http://www.cnblogs.com/edi ... -
Eclipse Class Decompiler——Java反编译插件
2014-10-16 11:02 431原文地址:http://bbs.csdn. ...
相关推荐
通过java,获取一个视频资源的播放时长!
FFmpeg解析视频,合并都可以,本项目只是用来获取视频长度,有点大材小用,但是目前能获取在线视频长度的资源的确是不多。VLC也是可以获取在线URL视频长度的,但是VLC有的在线视频也获取不到时长,这是补充方案,...
LibVLCSharp来获取视频文件的播放时长,代码简洁,比通过shell32好用多了(shell32有的系统不支持)。vs2019工程,全部代码,可编译测试。
ffmpeg获取视频时长,码率,编码格式,视频格式,分辨率,音频编码 ,音频采样频率等信息,用JAVA实现的。
在java中上传视频时根据需求,使用FFMpeg获取视频的时长
主要通过ffmpeg源码获取视频的时长,ffmpeg版本为4.0。
Java 获取视频时长、格式、大小需要的jar jave-1.0.2
调用vlc的dll,通过VLC的API来获取视频文件的时间长度信息,完整源代码,vs2008工程,可编译和测试通过。 需要注意的是使用的VLC 32位版本,C#工程必须设置生成32位软件。如果想用64位的,那么请使用64位的VLC版本的...
JAVA获取本地视频或者网络URL的时长。附代码和Jar包
自己写的一个用于记录视频播放时长的js,通过video标签的事件处理实现,文末有使用示例,引入即用。
给大家分享了利用PHP中的FFmpeg读取视频播放时长与码率等信息,有需要的朋友们可以参考借鉴。下面来一起看看吧。
C# 获取视频时长,并且视频截图,代码清晰明了,使用了ffmpeg.exe工具。
通过ffmpeg获取视频文件的视频时间长度信息,可以获取各种保存在本地的视频文件中的视频时长信息。完整的C代码和codeblocks工程,没有使用ffmpeg命令,是调用的ffmpeg API方式实现的,在linux下可直接编译和测试通过...
本地生成file文件 MultipartFile转为file,获取时长(毫秒),换算毫秒为时分秒 删除本地的file文件
直接通过element-ui自带的上传组件结合js即可,代码如下: ... before-upload=beforeAvatarUpload> <button class=ce-button not-hover primary> <i class=ce-icon_upload></i> 重新上传
工程已经打包,很详细的描述,所有工具都已打包好,这里主要是做了视频截图,视频播放时长的获取,其他的内容如果要获取自己可以重新添加命令获取。
利用ffmpeg获取视频封面图,时长信息
本java工程旨在演示如何使用Java代码获取播放文件的时长。 本工程编码方式:GBK; 支持的播放文件格式为:mp3、mp4、f4v、3gp、flv、rmvb、mkv,其它格式没有测试。
ios获取视频长度和当前播放时间