视频压缩转码FFmpegFrameRecorder

视频压缩转码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>-->

本文发布于:2024-09-22 23:23:37,感谢您对本站的认可!

本文链接:https://www.17tex.com/tex/2/236900.html

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。

标签:特率   压缩   设置   视频   传送数据   转码
留言与评论(共有 0 条评论)
   
验证码:
Copyright ©2019-2024 Comsenz Inc.Powered by © 易纺专利技术学习网 豫ICP备2022007602号 豫公网安备41160202000603 站长QQ:729038198 关于我们 投诉建议