之前使用Java的JAVE进行媒体基本信息的提取,但受限于早已过时,多年未更新,故使用流行的FFmpeg进行提取。
注意:受版权原因,针对rm及rmvb格式无法处理
准备工作:
FFmpeg下载网址:http://ffmpeg.org/download.html
1.提取后的原始数据:
2.核心代码:
ProcessBuilder processBuilder = new ProcessBuilder(ffmpegApp, "-y", "-i", videoFilename, "-vframes", "1", "-ss", "0:0:0", "-an", "-vcodec", "png", "-f", "rawvideo", "-s", "100*100", tmpFile);
Process process = processBuilder.start();
InputStream stderr = process.getErrorStream();
InputStreamReader isr = new InputStreamReader(stderr);
BufferedReader br = new BufferedReader(isr);
String line;
StringBuffer sb = new StringBuffer();
while ((line = br.readLine()) != null) {
sb.append(line);
}
3.正则提取相关信息
抱歉,暂时尚未测试完成