|
@@ -138,6 +138,9 @@ public class TbFileServiceImpl extends ServiceImpl<TbFileMapper, TbFile> impleme
|
|
|
|
|
|
|
|
//生成视频的封面图片文件(该方法内部会执行 FFmpeg 命令并验证)
|
|
//生成视频的封面图片文件(该方法内部会执行 FFmpeg 命令并验证)
|
|
|
String thumbnailFilePath = generateThumbnailFilePath(subFileName, file.getOriginalFilename());
|
|
String thumbnailFilePath = generateThumbnailFilePath(subFileName, file.getOriginalFilename());
|
|
|
|
|
+ // 说明:这行代码在windows下使用,在Linux下需要注释掉
|
|
|
|
|
+ thumbnailFilePath = thumbnailFilePath.replace("\\", "/");
|
|
|
|
|
+
|
|
|
String substring = thumbnailFilePath.substring(thumbnailFilePath.lastIndexOf("/upload"));
|
|
String substring = thumbnailFilePath.substring(thumbnailFilePath.lastIndexOf("/upload"));
|
|
|
substring = "/profile" + substring;
|
|
substring = "/profile" + substring;
|
|
|
log.info("生成视频的封面图片文件路径:{}", substring);
|
|
log.info("生成视频的封面图片文件路径:{}", substring);
|
|
@@ -245,9 +248,7 @@ public class TbFileServiceImpl extends ServiceImpl<TbFileMapper, TbFile> impleme
|
|
|
* @throws VideoThumbnailService.VideoProcessException 如果封面生成失败或验证失败
|
|
* @throws VideoThumbnailService.VideoProcessException 如果封面生成失败或验证失败
|
|
|
*/
|
|
*/
|
|
|
private String generateThumbnailFilePath(String videoPath, String originalFilename) throws IOException, VideoThumbnailService.VideoProcessException {
|
|
private String generateThumbnailFilePath(String videoPath, String originalFilename) throws IOException, VideoThumbnailService.VideoProcessException {
|
|
|
- // 1. 确保保存目录存在
|
|
|
|
|
- Path saveDir = Paths.get(videoPath);
|
|
|
|
|
- // 2. 生成唯一的封面文件路径
|
|
|
|
|
|
|
+ //生成唯一的封面图片文件路径
|
|
|
String baseFilename = getFileNameWithoutExtension(originalFilename);
|
|
String baseFilename = getFileNameWithoutExtension(originalFilename);
|
|
|
String thumbnailFileName = baseFilename + "_" + System.currentTimeMillis() + "_thumbnail.jpg";
|
|
String thumbnailFileName = baseFilename + "_" + System.currentTimeMillis() + "_thumbnail.jpg";
|
|
|
|
|
|