inputStream.start();
// 等待ffmpeg命令执行完
int exit = 0;
try {
exit = ffmpeg.waitFor();
} catch (InterruptedException e) {
e.printStackTrace();
}
LOG.info(“—执行结果:—” + (exit == 0 ? “【成功】” : “【失败】”));
if (exit == 0) {
originFile = new File(filePath);
if(originFile.exists()){
originFile.delete();
}
}
return exit;
}
/**
-
获取文件后缀
-
@param fileName
-
@return java.lang.String
-
@author zxzhang
-
@date 2019/12/10
*/
public String getExt(String fileName) {
return fileName.substring(fileName.lastIndexOf(“.”) + 1);
}
/**
-
获取文件所在目录
-
@param filePath
-
@return java.lang.String
-
@author zxzhang
-
@date 2019/12/10
*/
public String getFileDir(String filePath) {
return filePath.substring(0, filePath.lastIndexOf(BootstrapConst.PATH_SEPARATOR));
}
/**
-
获取文件名
-
@param filePath
-
@return java.lang.String
-
@author zxzhang
-
@date 2019/12/10
*/
public String getFileName(String filePath) {
return filePath.substring(filePath.lastIndexOf(BootstrapConst.PATH_SEPARATOR) + 1, filePath.lastIndexOf(“.”));
}
}
class PrintStream extends Thread {
java.io.InputStream __is = null;
public PrintStream(java.io.InputStream is) {
__is = is;
}
@Override
public void run() {
try {
while (this != null) {
int _ch = __is.read();
if (_ch != -1) {
System.out.print((char) _ch);
} else {
break;
}
}
} catch (Exception e) {
e.printStackTrace();
}
}
}
2、BootstrapConst类
package com.openailab.oascloud.file.common.consts;
/**
-
@Classname: com.openailab.oascloud.security.common.consts.BootstrapConst
-
@Description: 简单常量定义
-
@Author: zxzhang
-
@Date: 2019/10/8