mvn转mp4

jave-1.0.2.jar 下载  。 安装到maven使用

参考: https://blog.csdn.net/weixin_43064185/article/details/121823276

下载jar包到本地

mvn install:install-file -Dfile=D:\repository\jave-1.0.2\jave-1.0.2.jar -DgroupId=wg -DartifactId=jave -Dversion=1.0.2 -Dpackaging=jar

maven中引入:

<dependency>
    <groupId>wg</groupId>
    <artifactId>jave</artifactId>
    <version>1.0.2</version>
</dependency>

public static void main(String[] args) {
        try {
            String sourcePath = "C:\\Users\\hezha\\Desktop\\合成\\Video_2023-11-14_221008.wmv";
            String targetPath = "C:\\Users\\hezha\\Desktop\\合成\\Video_2023-11-14_221008.mp4";

            File source = new File(sourcePath);
            File target = new File(targetPath);

            // 创建转换器
            Encoder encoder = new Encoder();

           // 创建目标文件的编码格式
            EncodingAttributes attributes = new EncodingAttributes();
            attributes.setFormat("mp4");

            // 创建音频属性
            AudioAttributes audioAttributes = new AudioAttributes();
            audioAttributes.setCodec("aac"); // 设置音频编码器
            audioAttributes.setBitRate(256000); // 设置音频比特率
            audioAttributes.setChannels(2); // 设置音频通道数
            audioAttributes.setSamplingRate(44100); // 设置音频采样率
            attributes.setAudioAttributes(audioAttributes);

// 创建视频属性
            VideoAttributes videoAttributes = new VideoAttributes();
            videoAttributes.setCodec("mpeg4"); // 设置视频编码器
            videoAttributes.setBitRate(8000000); // 设置视频比特率,越大越高清
            videoAttributes.setFrameRate(60); // 设置视频帧率
            attributes.setVideoAttributes(videoAttributes);

            // 开始转换
            encoder.encode(new File(sourcePath), new File(targetPath), attributes);
            System.out.println("转换完成");
        } catch (EncoderException e) {
            e.printStackTrace();
        }
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值