|
@@ -0,0 +1,57 @@
|
|
1
|
+package com.xhkjedu.sstudy.service.resource;
|
|
2
|
+
|
|
3
|
+import com.alibaba.fastjson.JSON;
|
|
4
|
+import com.xhkjedu.sstudy.config.ConfigKey;
|
|
5
|
+import com.xhkjedu.sstudy.mapper.resource.ResourceMapper;
|
|
6
|
+import com.xhkjedu.sstudy.model.resource.TResource;
|
|
7
|
+import com.xhkjedu.utils.N_Utils;
|
|
8
|
+import com.xhkjedu.vo.ResultVo;
|
|
9
|
+import lombok.extern.slf4j.Slf4j;
|
|
10
|
+import org.springframework.stereotype.Service;
|
|
11
|
+
|
|
12
|
+import javax.annotation.Resource;
|
|
13
|
+import java.util.List;
|
|
14
|
+
|
|
15
|
+/**
|
|
16
|
+ * @Description:flv非h264格式视频转码
|
|
17
|
+ * @Author: WN
|
|
18
|
+ * @Date: 2024/9/14 16:16:02
|
|
19
|
+ **/
|
|
20
|
+@Slf4j
|
|
21
|
+@Service
|
|
22
|
+public class FlvUpdateResService {
|
|
23
|
+
|
|
24
|
+ @Resource
|
|
25
|
+ ResourceMapper resourceMapper;
|
|
26
|
+
|
|
27
|
+ /*
|
|
28
|
+ * @Description 如果flv编码不是h264格式,则设置资源带转换
|
|
29
|
+ * @Date 2024/9/14 16:33:23
|
|
30
|
+ * @Author WN
|
|
31
|
+ * @Param []
|
|
32
|
+ * @Return void
|
|
33
|
+ **/
|
|
34
|
+ public int hadnleFlvResource() {
|
|
35
|
+ List<TResource> resourceList = resourceMapper.listFlvResources();
|
|
36
|
+ int count = 0;
|
|
37
|
+ for (TResource resource : resourceList) {
|
|
38
|
+ String resourceid = resource.getResourceid();
|
|
39
|
+
|
|
40
|
+ String params = "filepath=" + resource.getResourceurl();
|
|
41
|
+ String fileInfoStr = N_Utils.sendPost(ConfigKey.fileapi + "video/vc", params);
|
|
42
|
+
|
|
43
|
+ ResultVo fileResult = JSON.parseObject(fileInfoStr, ResultVo.class);
|
|
44
|
+ if (fileResult.getCode() == 0 && N_Utils.isNotEmpty(fileResult.getObj())) {
|
|
45
|
+ String flvCode = fileResult.getObj().toString();
|
|
46
|
+ if (!"h264".equals(flvCode)) {
|
|
47
|
+ resourceMapper.updateFlvResconverted(resourceid, flvCode);
|
|
48
|
+ count++;
|
|
49
|
+ }else{
|
|
50
|
+ resourceMapper.updateFlvMp4code(resourceid, "h264");
|
|
51
|
+ }
|
|
52
|
+ }
|
|
53
|
+ }
|
|
54
|
+ return count;
|
|
55
|
+ }
|
|
56
|
+
|
|
57
|
+}
|