package com.wondertek;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.List;
import org.apache.oro.text.regex.MalformedPatternException;
import org.apache.oro.text.regex.MatchResult;
import org.apache.oro.text.regex.Pattern;
import org.apache.oro.text.regex.PatternCompiler;
import org.apache.oro.text.regex.PatternMatcher;
import org.apache.oro.text.regex.Perl5Compiler;
import org.apache.oro.text.regex.Perl5Matcher;
public class testConvert {
/**
* @param args
*/
public static void main(String[] args) {
String result = processFLV("D:\\video\\海豹突击队.Act.of.Valor.2012.BluRay.1080p.DTS.x264.rmvb");
PatternCompiler compiler =new Perl5Compiler();
try {
String regexDuration ="Duration: (.*?), start: (.*?), bitrate: (\\d*) kb\\/s";
String regexVideo ="Video: (.*?), (.*?), (.*?)[,\\s]";
String regexAudio ="Audio: (\\w*), (\\d*) Hz";
Pattern patternDuration = compiler.compile(regexDuration,Perl5Compiler.CASE_INSENSITIVE_MASK);
PatternMatcher matcherDuration = new Perl5Matcher();
if(matcherDuration.contains(result, patternDuration)){
MatchResult re = matcherDuration.getMatch();
System.out.println("提取出播放时间 ===" +re.group(1));
System.out.println("开始时间 =====" +re.group(2));
System.out.println("bitrate 码率 单位 kb==" +re.group(3));
}
Pattern patternVideo = compiler.compile(regexVideo,Perl5Compiler.CASE_INSENSITIVE_MASK);
PatternMatcher matcherVideo = new Perl5Matcher();
if(matcherVideo.contains(result, patternVideo)){
MatchResult re = matcherVideo.getMatch();
System.out.println("编码格式 ===" +re.group(1));
System.out.println("视频格式 ===" +re.group(2));
System.out.println("分辨率 ===" +re.group(3));
}
Pattern patternAudio = compiler.compile(regexAudio,Perl5Compiler.CASE_INSENSITIVE_MASK);
PatternMatcher matcherAudio = new Perl5Matcher();
if(matcherAudio.contains(result, patternAudio)){
MatchResult re = matcherAudio.getMatch();
System.out.println("音频编码 ===" +re.group(1));
System.out.println("音频采样频率 ===" +re.group(2));
}
} catch (MalformedPatternException e) {
e.printStackTrace();
}
}
private static String processFLV(String inputPath) {
List<String> commend = new java.util.ArrayList<String>();
// mmpeg的存放目录
commend.add("E:\\vidoConvert\\ffmpeg");
commend.add("-i");
commend.add(inputPath);
try {
ProcessBuilder builder = new ProcessBuilder();
builder.command(commend);
builder.redirectErrorStream(true);
Process p = builder.start();
// 1. start
BufferedReader buf = null; // 保存ffmpeg的输出结果流
String line = null;
buf = new BufferedReader(new InputStreamReader(p.getInputStream()));
StringBuffer sb = new StringBuffer();
while ((line = buf.readLine()) != null) {
System.out.println(line);
sb.append(line);
continue;
}
int ret = p.waitFor();// 这里线程阻塞,将等待外部转换进程运行成功运行结束后,才往下执行
// 1. end
return sb.toString();
} catch (Exception e) {
return null;
}
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
ffmpeg通过jakarta-oro获取视频信息
共8个文件
exe:4个
dll:2个
jar:1个
4星 · 超过85%的资源 需积分: 10 15 下载量 177 浏览量
2012-11-14
14:38:26
上传
评论 1
收藏 17.68MB RAR 举报
温馨提示
ffmpeg通过jakarta-oro获取视频的时长,码率,编码格式,视频格式,分辨率,音频编码,音频采样频率
资源推荐
资源详情
资源评论
收起资源包目录
ffmpeg.rar (8个子文件)
jakarta-oro.jar 64KB
mmpeg
mplayer.exe 18.3MB
dsnative.dll 140KB
mencoder.exe 16.84MB
pthreadGC2.dll 86KB
ffplay.exe 7.94MB
ffmpeg.exe 7.58MB
testConvert.java 3KB
共 8 条
- 1
资源评论
- n158653861362013-08-09还是不够完美。
- manbanpaic2013-04-09能够解决一般的视频 但是Duration:N/A的情况不知道该怎么获取
- huanggengshuai2013-04-28可以获取视频信息,但能否提供c语言写的程序。
- axiaoyaoyou2014-06-22还不错,有待改善
kasirin
- 粉丝: 0
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功