视频压缩转码FFmpegFrameRecorder 代码 /**
* 视频压缩
* movToMp4("C:/mysoftware/video/test188.mp4","C:/mysoftware/video/test188temp.mp4");
* @param sourcePath 视频来源tmal
* @param targetPath 压缩后的视频地址
如何自制夹蛋器*/
private void movToMp4(String sourcePath, String targetPath) {
File source = new File(sourcePath);
File target = new File(targetPath);
long beginTime = System.currentTimeMillis();
AudioAttributes audio = new AudioAttributes();
audio.setCodec("libmp3lame");//aac
//⽐特率是指每秒传送的⽐特(bit)数。单位为 bps(Bit Per Second),⽐特率越⾼,传送数据速度越快 audio.setBitRate(new Integer(80000));//设置⽐特率 audio.setChannels(new Integer(1));//设置声⾳频道
audio.setSamplingRate(new Integer(22050));//设置节录率
VideoAttributes video = new VideoAttributes();
video.setCodec("h264");
video.setBitRate(new Integer(2325 * 1024));
//⽐特率是指每秒传送的⽐特(bit)数。单位为 bps(Bit Per Second),⽐特率越⾼,传送数据速度越快
// video.setBitRate(new Integer(800000));//设置⽐特率
video.setFrameRate(new Integer(60));//设置帧率,越⼤越流畅,越⼩越卡
EncodingAttributes attrs = new EncodingAttributes();
attrs.setFormat("mp4");
attrs.setAudioAttributes(audio);
精炼剂
attrs.setVideoAttributes(video);
Encoder encoder = new Encoder();
try {
真空浇注de(new MultimediaObject(source), target, attrs);
System.out.println("压缩完成花费时间是:" + ((System.currentTimeMillis() - beginTime))/1000 + "秒");
} catch (IllegalArgumentException | EncoderException e) {
e.printStackTrace();
}
}
⽀持 Maven
<!-- 压缩视频 -->
<properties>
<java.version>1.8</java.version>
<bytedeco.version>1.4.1</bytedeco.version>
<bytedeco.javacpp.version>3.4.1-1.4.1</bytedeco.javacpp.version> <bytedeco.javacpp-presets>3.4.2-1.4.1</bytedeco.javacpp-presets> <schild.version>2.7.1</schild.version>
</properties>
热熔铜螺母
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-all-deps</artifactId>
<version>${schild.version}</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-core</artifactId>
<version>${schild.version}</version>
离子风机aryang
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-win64</artifactId>
<version>${schild.version}</version>
</dependency>
<!--<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-linux64</artifactId>
<version>${schild.version}</version>
</dependency>
<dependency>
<groupId>ws.schild</groupId>
<artifactId>jave-nativebin-osx64</artifactId>
<version>${schild.version}</version>
</dependency>-->