FFmpeg 官网: https://ffmpeg.org
FFmpeg在Windows下的安装:https://blog.csdn.net/wang_shu_/article/details/139981355
需求
- 上传文件
- 视频获取宽高、时长、封面
- 音频获取时长
- 图片获取宽高
- 非MP4格式视频需转码为MP4存储,用于后续web端预览,其他格式可能出现兼容性文档
Linux安装FFmpeg:
sudo add-apt-repository ppa:jonathonf/ffmpeg-4
sudo apt-get update
sudo apt-get install ffmpeg
ffmpeg -version
Springboot 集成
-
添加 pom 依赖
<dependency> <groupId>ws.schild</groupId> <artifactId>jave-all-deps</artifactId> <version>3.3.1</version> <exclusions> <!-- 排除不需要的平台依赖 --> <exclusion> <groupId>ws.schild</groupId> <artifactId>jave-nativebin-win32</artifactId> </exclusion> <exclusion> <groupId>ws.schild</groupId> <artifactId>jave-nativebin-linux32</artifactId> </exclusion> <exclusion> <groupId>ws.schild</groupId> <artifactId>jave-nativebin-osx64</artifactId> </exclusion> <exclusion> <groupId>ws.schild</groupId> <artifactId>jave-nativebin-osxm1</artifactId> </exclusion> <exclusion>