public boolean ompressionVedio(String filePath, String newFilePath){
boolean sucess = false;
File oldFile = new File(filePath);
File newFile = new File(newFilePath);
MultimediaObject object = new MultimediaObject(oldFile);
try {
AudioInfo audioInfo = object.getInfo().getAudio();
int maxBitRate = 128000;
int maxSamplingRate = 44100;
int bitRate = 800000;
int maxFrameRate = 20;
VideoAttributes video = new VideoAttributes();
video.setCodec("h264");
video.setFrameRate(maxFrameRate);
video.setSize(new VideoSize(1920, 1080));
EncodingAttributes attr = new EncodingAttributes();
attr.setFormat("mp4");
attr.setVideoAttributes(video);
Encoder encoder = new Encoder();
encoder.encode(new MultimediaObject(oldFile), newFile, attr);
sucess = true;
}catch (Exception e){
e.printStackTrace();
}
return sucess;
}
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>2.7.3</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>2.7.3</version>
</dependency>