java实现多图合成mp4和视频附件下载
在wutool
中,封装了视频处理工具类,基于javacv
和ffmpeg
库,实现多图合成mp4、视频http附件下载等。
关于wutool
wutool
是一个java代码片段收集库,针对特定场景提供轻量解决方案,只要按需选择代码片段拷贝使用即可。项目git地址https://github.com/handsomestWei/wutool
,欢迎star
视频处理工具类使用
代码片段地址https://github.com/handsomestWei/wutool/tree/main/src/main/java/com/wjy/wutool/util/MediaUtil.java
maven依赖
xml
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>javacv</artifactId>
<exclusions>
<exclusion>
<groupId>org.bytedeco</groupId>
<artifactId>openblas</artifactId>
</exclusion>
</exclusions>
<version>1.5.6</version>
</dependency>
<dependency>
<groupId>org.bytedeco</groupId>
<artifactId>ffmpeg-platform</artifactId>
<version>4.4-1.5.6</version>
</dependency>
多张图片合成mp4
java
/**
* @param outPutFilePath 视频mp4文件输出路径
* @param picUrlList 待合成的图片列表。图片url支持文件、链接等多种形式
*/
public static Boolean compositeMp4(String outPutFilePath, List<String> picUrlList);
视频http附件下载
视频文件将会以http附件的方式提供文件下载
java
/**
* @param response http请求响应对象
* @param mediaFile 视频文件对象
*/
public static void rspAttachment(HttpServletResponse response, File mediaFile);