|
|
@@ -45,7 +45,17 @@ public class VideoUtils {
|
|
|
}
|
|
|
|
|
|
// 调用ffmpeg 执行截取命令,需要服务器中安装了ffmpeg并配置了环境变量
|
|
|
- processBuilder.command(ffmpegPath, "-i", videoFilePath, "-ss", "00:00:01", "-vframes", "1", imgFilePath);
|
|
|
+// processBuilder.command(ffmpegPath, "-i", videoFilePath, "-ss", "00:00:00", "-vframes", "1", imgFilePath);
|
|
|
+ // 核心修改1:调整-ss位置到-i前面,补充-y(覆盖文件)和-f image2(格式兼容)
|
|
|
+ processBuilder.command(
|
|
|
+ ffmpegPath,
|
|
|
+ "-ss", "00:00:00", // 先定位到0秒(第一帧),再读视频,提升精准度
|
|
|
+ "-i", videoFilePath, // 输入视频文件
|
|
|
+ "-vframes", "1", // 只截取1帧
|
|
|
+ "-f", "image2", // 显式指定图片格式,兼容更多视频类型
|
|
|
+ "-y", // 覆盖已存在的图片文件,避免进程阻塞
|
|
|
+ imgFilePath // 输出图片路径
|
|
|
+ );
|
|
|
try {
|
|
|
Process process = processBuilder.start();
|
|
|
// 获取流信息
|