java实现,无损视频大小压缩
java实现,无损视频大小压缩。<!--依赖--><!-- https://mvnrepository.com/artifact/it.sauronsoftware/jave --><dependency><groupId>it.sauronsoftware</groupId><artifactId>jave</arti
·
java实现,无损视频大小压缩。
<!--依赖-->
<!-- https://mvnrepository.com/artifact/it.sauronsoftware/jave -->
<dependency>
<groupId>it.sauronsoftware</groupId>
<artifactId>jave</artifactId>
<version>1.0.2</version>
</dependency>
代码
import it.sauronsoftware.jave.AudioAttributes;
import it.sauronsoftware.jave.Encoder;
import it.sauronsoftware.jave.EncodingAttributes;
import it.sauronsoftware.jave.VideoAttributes;
import java.io.File;
public class mian {
public static void main(String[] args) {
//原
File source = new File("F:\\MP4\\old\\1.mp4");
//新
File target = new File("F:\\MP4\\new\\1.mp4");
try {
System.out.println("begin");
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");
audio.setBitRate(new Integer(56000));
audio.setChannels(new Integer(1));
audio.setSamplingRate(new Integer(22050));
VideoAttributes video = new VideoAttributes();
video.setCodec("mpeg4");
video.setBitRate(new Integer(800000));
video.setFrameRate(new Integer(15));
EncodingAttributes attr = new EncodingAttributes();
attr.setFormat("mp4");
attr.setAudioAttributes(audio);
attr.setVideoAttributes(video);
Encoder encoder = new Encoder();
encoder.encode(source, target, attr);
System.out.println("end");
} catch (Exception e) {
e.printStackTrace();
}
}
}
更多推荐
已为社区贡献1条内容
所有评论(0)