YSP样例文件增加时长验证功能。
This commit is contained in:
@@ -38,6 +38,11 @@ import com.nis.util.StringUtil;
|
||||
import com.nis.web.controller.BaseController;
|
||||
import com.nis.web.security.UserUtils;
|
||||
|
||||
import it.sauronsoftware.jave.AudioInfo;
|
||||
import it.sauronsoftware.jave.Encoder;
|
||||
import it.sauronsoftware.jave.MultimediaInfo;
|
||||
import it.sauronsoftware.jave.VideoInfo;
|
||||
|
||||
/**
|
||||
* 处理音视频业务
|
||||
* @author zhangwei
|
||||
@@ -157,11 +162,33 @@ public class AvController extends BaseController {
|
||||
|
||||
// entity.setSrcMd5(srcMd5);
|
||||
// entity.setSampleMd5(sampleMd5);
|
||||
//验证音视频文件时长
|
||||
Encoder encoder = new Encoder();
|
||||
String length = "";
|
||||
try {
|
||||
MultimediaInfo m = encoder.getInfo(uploadSrcFile);
|
||||
long ls = m.getDuration()/1000;
|
||||
int hour = (int) (ls/3600);
|
||||
int minute = (int) (ls%3600)/60;
|
||||
int second = (int) (ls-hour*3600-minute*60);
|
||||
length = hour+"'"+minute+"''"+second+"'''";
|
||||
logger.info(uploadSrcFile.getName()+"时长:"+length);
|
||||
if(ls>0 && second>Constants.AV_DURATION_LIMIT){
|
||||
addMessage(redirectAttributes,"exceeds_duration_limit");
|
||||
logger.error("The duration of uploaded files exceeds the limit("+Constants.AV_DURATION_LIMIT+"s).");
|
||||
return "redirect:" + adminPath +"/ntc/av/sample/fileSampleList?functionId="+entity.getFunctionId();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
addMessage(redirectAttributes,"save_failed");
|
||||
return "redirect:" + adminPath +"/ntc/av/sample/fileSampleList?functionId="+entity.getFunctionId();
|
||||
}
|
||||
}
|
||||
|
||||
avCfgService.saveOrUpdateAvFileSample(entity, srcFile);
|
||||
addMessage(redirectAttributes,"save_success");
|
||||
|
||||
|
||||
}catch(Exception e){
|
||||
logger.error("文件上传失败",e);
|
||||
e.printStackTrace();
|
||||
|
||||
Reference in New Issue
Block a user