65 lines
2.1 KiB
Java
65 lines
2.1 KiB
Java
package com.ddnai.web.controller.system;
|
||
|
||
import org.springframework.web.bind.annotation.GetMapping;
|
||
import org.springframework.web.bind.annotation.RequestMapping;
|
||
import org.springframework.web.bind.annotation.RestController;
|
||
import com.ddnai.common.core.controller.BaseController;
|
||
import com.ddnai.common.core.domain.AjaxResult;
|
||
import com.ddnai.common.utils.file.VideoDurationUtils;
|
||
import java.util.HashMap;
|
||
import java.util.Map;
|
||
|
||
/**
|
||
* FFmpeg状态检查控制器
|
||
* 用于诊断视频时长提取功能
|
||
*
|
||
* @author ddnai
|
||
*/
|
||
@RestController
|
||
@RequestMapping("/system/ffmpeg")
|
||
public class FFmpegStatusController extends BaseController
|
||
{
|
||
/**
|
||
* 检查FFmpeg是否可用
|
||
*/
|
||
@GetMapping("/status")
|
||
public AjaxResult checkFFmpegStatus()
|
||
{
|
||
Map<String, Object> result = new HashMap<>();
|
||
|
||
try
|
||
{
|
||
// 检查FFmpeg是否可用
|
||
boolean isAvailable = VideoDurationUtils.isFFmpegAvailable();
|
||
result.put("available", isAvailable);
|
||
|
||
if (isAvailable)
|
||
{
|
||
result.put("message", "✓ FFmpeg已安装且可用");
|
||
result.put("status", "success");
|
||
}
|
||
else
|
||
{
|
||
result.put("message", "✗ FFmpeg不可用或未安装");
|
||
result.put("status", "error");
|
||
result.put("solution", new String[]{
|
||
"1. 下载FFmpeg: https://ffmpeg.org/download.html",
|
||
"2. 解压到系统目录(如 C:\\ffmpeg)",
|
||
"3. 添加到系统PATH环境变量",
|
||
"4. 重启应用服务器",
|
||
"或者:在后台管理系统中手动设置视频时长"
|
||
});
|
||
}
|
||
|
||
return AjaxResult.success(result);
|
||
}
|
||
catch (Exception e)
|
||
{
|
||
result.put("available", false);
|
||
result.put("message", "检查FFmpeg状态时发生错误: " + e.getMessage());
|
||
result.put("status", "error");
|
||
return AjaxResult.error("检查FFmpeg状态失败", result);
|
||
}
|
||
}
|
||
}
|