Java读取视频时长
JAVEThe JAVE (Java Audio Video Encoder) library is Java wrapper on the ffmpeg project. Developers can take take advantage of JAVE to transcode audio and video files from a format to another. In example you can transcode an AVI file to a MPEG one, you can change a DivX video stream into a (youtube like) Flash FLV one, you can convert a WAV audio file to a MP3 or a Ogg Vorbis one, you can separate and transcode audio and video tracks, you can resize videos, changing their sizes and proportions and so on. Many other formats, containers and operations are supported by JAVE. 如下网址是此工具包下载地址:http://www.sauronsoftware.it/projects/jave/index.php
用该API读取视频属性实例代码如下:
- package com.itheima;
- import it.sauronsoftware.jave.Encoder;
- import it.sauronsoftware.jave.MultimediaInfo;
- import java.io.File;
- public class ReadVideo {
- public static void main(String[] args){
- File source = new File("E:\\测试视频\\R41.avi");
- Encoder encoder = new Encoder();
- try {
- MultimediaInfo m = encoder.getInfo(source);
- long ls = m.getDuration();
- System.out.println("此视频时长为:"+ls/60000+"分"+(ls`000)/1000+"秒!");
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
复制代码
|
|