Linux上搭建并使用ffmpeg(Java)

原网址:https://blog.csdn.net/Just_do_it_HZF/article/details/136404728

关于MacOs和Windows系统上使用ffmpeg就不多说了,有很多相关文章,今天给大家分享一个在Linux环境下使用Java语言来使用ffmpeg

一、首先去官网下载一个Linux对应的ffmpeg包
1、进入ffmpeg官网:官网
2、点击左侧导航栏Download


3、选择Linux对应的安装包:


4、点击进入->选择ffmpeg-release-amd64-static.tar.xz - md5进行下载:


5、解压文件:
tar -zxvf ffmpeg-release-amd64-static.tar.xz
6、解压以后我们就可以看到ffmpeg/ffprobe等文件:


7、如果想要全局使用ffmpeg指令,那么需要进入到/usr/local/bin下来引入下载好的ffmpeg/probe,执行以下指令:
路径/usr/local/ffmpeg6.1为自己Linux安装的ffmpeg路径
ln -s /usr/local/ffmpeg6.1/ffmpeg
ln -s /usr/local/ffmpeg6.1/ffmpeg
二、在Idea中使用ffmpeg
public static void voiceChangeFormat(String localPath, String targetPath) {
List<String> command = new ArrayList<>();
command.add("ffmpeg");
command.add("-i");
command.add(localPath);
command.add("-ar");
command.add("8000");
command.add("-ab");
command.add("12.2k");
command.add("-ac");
command.add("1");
command.add(targetPath);
commandStart(command);
}
commandStart方法请看上一篇文章:Java使用ffmpeg指令实现音频格式转换-CSDN博客
————————————————

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/Just_do_it_HZF/article/details/136404728

posted @ 2024-05-27 15:27  xxb1  阅读(104)  评论(0编辑  收藏  举报