Java processing video, audio files (read video length, etc.) - JAVE

 
Brief introduction
 
        The 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.
 
        See the introduction so powerful, in fact, my needs just want to get the length of video, voice only.
 

use

 
        A total of only a jar package, API is very simple, do not say, paste the code
        
        Reads the video length
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package  com.jave;
 
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 /  1000  "秒!" );
         catch  (Exception e) {
             e.printStackTrace();
         }
     }
 
}
 

reference
 
Code
        jar, documentation and source code links: http://pan.baidu.com/s/1c1s9bqS  Password: oetx
 
Published 201 original articles · 98 won praise · views 770 000 +

Guess you like

Origin blog.csdn.net/Jerome_s/article/details/54348124