maven仓库里面是没有的,所以自己下载
http://www.sauronsoftware.it/projects/jave/download.php
JAVE 官方文档,还有很多其他方法可以查看
下载jave.1.02.jar包
下载后
放在resources目录下,pom文件如下:
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId>
<version>1.0.2</version>
<scope>system</scope>
<systemPath>${project.basedir}/src/main/resources/libs/jave-1.0.2.jar</systemPath>
</dependency>
然后plugin里面加上 <includeSystemScope>true</includeSystemScope>,maven打包就没问题了完整如下:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<includeSystemScope>true</includeSystemScope>
</configuration>
</plugin>
完整代码:
public static void main(String[] args) throws EncoderException {
String filename = "D:\\Marvel\\heiguafu.mp4";
File source = new File(filename);
Encoder encoder = new Encoder();
MultimediaInfo m = encoder.getInfo(source);
long millisecond = m.getDuration();//总的毫秒数,可以自己根据毫秒转换成分钟,或者秒数之类的
VideoInfo video = m.getVideo();//视频文件
// AudioInfo audio = m.getAudio();//如果是音频文件可以用这个方法
VideoSize size = video.getSize();
int height = size.getHeight();//高
int width = size.getWidth();//宽
int duration = (int) ((millisecond /1000));//秒
int bitRate = video.getBitRate();//码流(Kb)
float frameRate = video.getFrameRate();//封装格式
String decoder = video.getDecoder();
String format = m.getFormat();
System.out.println("duration----"+duration);
System.out.println("height----"+height);
System.out.println("width----"+width);
System.out.println("bitRate-----"+bitRate);
System.out.println("frameRate-----"+frameRate);
System.out.println("decoder-----"+decoder);
System.out.println("format----"+format);
}
运行结果: