forked from dyf/fys-Multi-tenant
- 新增BGR565格式转换逻辑,支持RGB565与BGR565两种颜色格式- 视频上传接口增加code参数,默认值为1(RGB565) - 在VideoProcessUtil中实现convertFramesToBGR565方法 - 添加bgr565ToMp4工具方法用于将BGR565数据编码为MP4文件 - MQTT规则新增对“设备已收到通知”的处理逻辑 - 设备确认消息后更新数据库日志状态并推送SSE消息 - 引入ScheduledExecutorService延时推送SSE消息- 增加设备日志和设备Mapper依赖以支持数据操作
68 lines
2.5 KiB
Java
68 lines
2.5 KiB
Java
package com.fuyuanshen.app.controller;
|
||
|
||
import cn.dev33.satoken.annotation.SaIgnore;
|
||
import com.fuyuanshen.app.service.AudioProcessService;
|
||
import com.fuyuanshen.app.service.VideoProcessService;
|
||
import com.fuyuanshen.common.core.domain.R;
|
||
import com.fuyuanshen.common.idempotent.annotation.RepeatSubmit;
|
||
import com.fuyuanshen.common.web.core.BaseController;
|
||
import lombok.RequiredArgsConstructor;
|
||
import org.springframework.http.MediaType;
|
||
import org.springframework.validation.annotation.Validated;
|
||
import org.springframework.web.bind.annotation.*;
|
||
import org.springframework.web.multipart.MultipartFile;
|
||
|
||
import java.io.IOException;
|
||
import java.util.Base64;
|
||
import java.util.List;
|
||
import java.util.concurrent.TimeUnit;
|
||
|
||
/**
|
||
* APP 视频处理控制器
|
||
*/
|
||
@Validated
|
||
@RequiredArgsConstructor
|
||
@RestController
|
||
@RequestMapping("/app/video")
|
||
public class AppVideoController extends BaseController {
|
||
|
||
private final VideoProcessService videoProcessService;
|
||
private final AudioProcessService audioProcessService;
|
||
|
||
/**
|
||
* 上传视频转码code默认1:RGB565 2:BGR565
|
||
*/
|
||
@PostMapping(value = "/upload", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
|
||
public R<List<String>> uploadVideo(@RequestParam("file") MultipartFile file, @RequestParam(defaultValue = "1") int code) {
|
||
return R.ok(videoProcessService.processVideo(file, code));
|
||
}
|
||
|
||
/**
|
||
* 上传音频文件并转码
|
||
*/
|
||
@PostMapping(value = "/audio", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
|
||
public R<List<String>> uploadAudio(@RequestParam("file") MultipartFile file) {
|
||
return R.ok(audioProcessService.processAudio(file));
|
||
}
|
||
|
||
/**
|
||
* 文字转音频TTS服务
|
||
*/
|
||
@GetMapping("/audioTTS")
|
||
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
|
||
public R<List<String>> uploadAudioTTS(@RequestParam String text) throws IOException {
|
||
return R.ok(audioProcessService.generateStandardPcmData(text));
|
||
}
|
||
|
||
/**
|
||
* 提取文本内容(只支持txt/docx)
|
||
*/
|
||
@PostMapping(value = "/extract", consumes = MediaType.MULTIPART_FORM_DATA_VALUE)
|
||
@RepeatSubmit(interval = 2, timeUnit = TimeUnit.SECONDS,message = "请勿重复提交!")
|
||
public R<String> extract(@RequestParam("file") MultipartFile file) throws Exception {
|
||
return R.ok("Success",audioProcessService.extract(file));
|
||
}
|
||
}
|