代码拉取完成,页面将自动刷新
package cn.angs;
import java.io.*;
import static cn.angs.FileUtil.loadRecourseFromJarByFolder;
/**
* ClassName: DefaultFFMPEGLocator.java
* Description: 默认的ffmpeg可执行定位器,运行时在程序临时文件目录生成ffmpeg执行文件,
* 适配windows、linux、mac系统
*
* @author wangshun@cloudwalk.cn
* @version 1.0.0
* @date 2021/07/22 13:47
*/
public class DefaultFFMPEGLocator extends AbstractFFMPEGLocator {
/**
* 追踪版本
*/
private static final int myEXEversion = 1;
/**
* ffmpeg路径.
*/
private String path;
private static final String WIN = "windows";
private static final String MAC = "mac";
/**
* 构建默认的FFMPEGLocator实例,并且导出ffmpeg执行文件到临时目录
*/
public DefaultFFMPEGLocator() {
String os = System.getProperty("os.name").toLowerCase();
// Windows?
boolean isWindows = os.contains(WIN);
//MacOS
boolean isMacOS = os.contains(MAC);
File temp = new File(System.getProperty("java.io.tmpdir"), "jave-"
+ myEXEversion);
if (!temp.exists()) {
temp.mkdirs();
temp.deleteOnExit();
}
String relativePath;
if (isMacOS) {
relativePath = "macos10";
} else if (isWindows) {
relativePath = "window";
} else {
relativePath = "linux";
}
String _temp = temp.getPath() + File.separator;
String ffmpeg = isWindows ? "ffmpeg.exe" : "ffmpeg";
String absolutePath;
if (isWindows) {
absolutePath = temp + File.separator + "system" + File.separator + relativePath + File.separator + "bin" + File.separator + ffmpeg;
} else {
absolutePath = temp + File.separator + "system" + File.separator + relativePath + File.separator + ffmpeg;
}
File ffmpegFile = new File(absolutePath);
if (!ffmpegFile.exists()) {
loadRecourseFromJarByFolder("/system/" + relativePath, _temp, this.getClass());
if (!isWindows) {
Runtime runtime = Runtime.getRuntime();
try {
runtime.exec(new String[]{"/bin/chmod", "755",
absolutePath});
} catch (IOException e) {
e.printStackTrace();
}
}
}
this.path = absolutePath;
}
@Override
protected String getFFMPEGExecutablePath() {
return path;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。