java 转码%2f%_java实现视频转码

packagecom.gcsoft.pyas.sysbase.utils;importcom.gcsoft.pyas.AppProperties;importorg.slf4j.Logger;importorg.slf4j.LoggerFactory;importorg.springframework.beans.factory.annotation.Autowired;importorg.springframework.stereotype.Component;importjava.io.File;importjava.io.IOException;importjava.io.InputStream;importjava.util.ArrayList;importjava.util.List;importjava.util.UUID;/*** 视频转码工具类

*

*@authorjwc*/@Componentpublic classConverVideoUtils {

@AutowiredprivateAppProperties appProperties;protected final Logger logger = LoggerFactory.getLogger(this.getClass());/*** 转换视频格式

*

*@paramsourceVideoPath 视频地址

*@return

*/

publicString beginConver(String sourceVideoPath) {//转码格式

String targetExtension =appProperties.getVideoFormat();//是否删除原文件

Boolean isDeleteResult =appProperties.getIsDeleteResult();

File fi= newFile(sourceVideoPath);

String fileName=fi.getName();//文件名不带扩展名

String fileRealName = fileName.substring(0, fileName.lastIndexOf("."));

logger.info("接收到文件(" + sourceVideoPath + ")需要转换");if (!checkfile(sourceVideoPath)) {

logger.error(sourceVideoPath+ "文件不存在" + " ");return "";

}long beginTime =System.currentTimeMillis();

logger.info("开始转文件(" + sourceVideoPath + ")");

String path=process(fileRealName, sourceVideoPath, targetExtension, isDeleteResult);if(StringUtil.isNotEmpty(path)) {

logger.info("转换成功");long endTime =System.currentTimeMillis();long timeCha = (endTime -beginTime);

String totalTime=sumTime(timeCha);

logger.info("转换视频格式共用了:" + totalTime + " ");if(isDeleteResult) {

deleteFile(sourceVideoPath);

}returnpath;

}else{return "";

}

}/*** 实际转换视频格式的方法

*

*@paramfileRealName 文件名不带扩展名

*@paramsourceVideoPath 原文件地址

*@paramtargetExtension 目标视频扩展名

*@paramisDeleteResult 转换完成后是否删除源文件

*@return

*/

private String process(String fileRealName, String sourceVideoPath, String ta

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值