迅睿CMS框架是一款PHP8高性能·简单易用的CMS开源开发框架,基于MIT开源许可协议发布,免费且不限制商业使用,是免费开源的产品,以万端互联为设计理念,支持的微信公众号、小程序、APP客户端、移动端网站、PC网站等多终端式管理系统。
联系官方销售客服
1835022288
028-61286886
上传视频,有截取画面的功能?
截取一个当做播放器画面
视频上传至oss后截帧获取视频封面图工具类:
/*** 视频处理:视频截帧生成封面图** @author LH_Yu* @Param uploadFile 上传文件* @Param videoPath 原视频key* @Param coverPicturePath 封面图上传路径及取出url的key* "%s|sys/saveas,o_%s,b_%s" 具体处理格式化*/public static String coverPicture(MultipartFile uploadFile, String videoPath, String coverPicturePath) throws Exception {// 创建OSSClient实例。OSSClient ossClient = new OSSClient(endpoint, accessKeyId, accessKeySecret);// 图片处理持久化 : 截帧生成封面图StringBuilder sbStyle = new StringBuilder();Formatter styleFormatter = new Formatter(sbStyle);//设置图片处理String styleType = "video/snapshot,t_3000,f_jpg,w_800,h_0,m_fast";//视频处理String targetImage = coverPicturePath + uploadFile.getOriginalFilename();styleFormatter.format("%s|sys/saveas,o_%s,b_%s", styleType,BinaryUtil.toBase64String(targetImage.getBytes()),BinaryUtil.toBase64String(bucketName.getBytes()));ProcessObjectRequest request = new ProcessObjectRequest(bucketNamePrivate, videoPath + uploadFile.getOriginalFilename(), sbStyle.toString());GenericResult processResult = ossClient.processObject(request);processResult.getResponse().getContent().close();//设置过期时间 -- 十年Date expiration = new Date(new Date().getTime() + 3600l * 1000 * 24 * 365 * 10);String url = ossClient.generatePresignedUrl(bucketName, coverPicturePath + uploadFile.getOriginalFilename(), expiration).toString();return url;}
视频上传至oss后截帧获取视频封面图工具类: