视频转换

/**
* 将视频文件下载到本地<br>
* 存放名称为UcmObject 对象ID跟图片后缀名
*
* @param fileId
*/
public static void downLoadFile(S2PersistentObjectContext object){
InputStream in = null;
OutputStream out = null;
try{
if(object == null){
logger.error("downLoadFile : null object");
return;
}
String suffix = FileUtils.getSuffix(object.getName());
String newFileName = object.getMd5()+"."+suffix;
//服务器文件路径
File aimFile = null;
if(suffix.equals("flv")){
aimFile = new File(VideoUtils.getFlvFolderPath(object.getMd5()) + newFileName);
}else{
aimFile = new File(VideoUtils.getVideoFolderPath(object.getMd5()) + newFileName);
}
in = object.getResource();
out = new FileOutputStream(aimFile);
byte[] buffer = new byte[8 * 1024];
int i = -1;
while ((i = in.read(buffer)) != -1) {
out.write(buffer, 0, i);
}
out.flush();
} catch (IOException e) {
//记录视频文件下载
logger.error("video download error ioException:", e);
printLog(object.getId(),"content.videoFile.downFileFail " + e);
} catch (S2Exception e) {
//记录视频文件下载
logger.error("video download error s2Exception:", e);
printLog(object.getId(),"content.videoFile.downFileFail " + e);
} finally {
IOUtils.closeQuietly(out);
IOUtils.closeQuietly(in);
}
}


/**
* 执行文件转换并保存到本地flv文件夹
*/
@SuppressWarnings("unchecked")
public static void processFLV(String inputPath, String savename,
String exePath) {
// 视频截取图片
GetPicFromVideo(inputPath, savename, exePath);
try {
List<String> commend = new ArrayList();
commend.add(exePath);
commend.add("-y");
commend.add("-i");
commend.add(inputPath);
commend.add("-ab");
commend.add("56");
commend.add("-ar");
commend.add("22050");
commend.add("-qscale");
commend.add("8");
commend.add("-r");
commend.add("15");
commend.add("-s");
commend.add("600x500");
commend.add(savename + ".flv");
ProcessBuilder builder = new ProcessBuilder(commend);
builder.start();
} catch (Exception e) {
LogManager logManager = SpringContextUtils.getBean("logManager");
String logContent = BundleUtil
.getText(OicConsts.BUNDLE_LOG,
"content.video.trans.exception",
new Object[] { inputPath });
OicLog oicLog = new LogBuilder(LogCatalog.VIEWTYPE_CREATE_FALL,
"system", logContent).build();
logManager.saveLog(oicLog);
logger.error("processFLV", e);
}
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值