视频转码
This commit is contained in:
@@ -173,5 +173,12 @@ public class CommonConstants {
|
|||||||
public static final String SEVEN_DAY="第七天-道具安装、室外招牌安装";
|
public static final String SEVEN_DAY="第七天-道具安装、室外招牌安装";
|
||||||
public static final String EIGHT_DAY="第八天-卫生保洁、网络及收银设备安装、撤场交接";
|
public static final String EIGHT_DAY="第八天-卫生保洁、网络及收银设备安装、撤场交接";
|
||||||
public static final String WITHDRAWAL="撤场";
|
public static final String WITHDRAWAL="撤场";
|
||||||
|
public static final String TRANSCODE_VIDEO = "mp4";
|
||||||
|
public static final String PRODUCT_REMIND = "product_remind";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 返回成功描述
|
||||||
|
*/
|
||||||
|
public static final String SUCCESS_STR = "success";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
package com.cool.store.enums.video;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Function;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
public enum AlarmTypeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 区域入侵
|
||||||
|
*/
|
||||||
|
REGION_INTRUSION("region_intrusion","区域入侵"),
|
||||||
|
/**
|
||||||
|
* 排队告警
|
||||||
|
*/
|
||||||
|
WAITING_ALARM("waiting_alarm","排队告警");
|
||||||
|
|
||||||
|
private String code;
|
||||||
|
private String msg;
|
||||||
|
|
||||||
|
protected static final Map<String, AlarmTypeEnum> map = Arrays.stream(values()).collect(
|
||||||
|
Collectors.toMap(AlarmTypeEnum::getCode, Function.identity()));
|
||||||
|
|
||||||
|
AlarmTypeEnum(String code, String msg){
|
||||||
|
this.code=code;
|
||||||
|
this.msg=msg;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCode() {
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMsg() {
|
||||||
|
return msg;
|
||||||
|
}
|
||||||
|
public static AlarmTypeEnum getByCode(String code) {
|
||||||
|
return map.get(code);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.cool.store.enums.video;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* video status
|
||||||
|
*/
|
||||||
|
public enum ResourceStatusEnum {
|
||||||
|
|
||||||
|
UPLOADING(0),// 上传中
|
||||||
|
|
||||||
|
TRANSCODING(1),// 转码中
|
||||||
|
|
||||||
|
SCREENSHOT_FINISHED(2),//截图完成
|
||||||
|
|
||||||
|
TRANSCODE_FINISH(3),//完成
|
||||||
|
|
||||||
|
TRANSCODE_FAILED(4);//失败
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer value;
|
||||||
|
|
||||||
|
ResourceStatusEnum(Integer value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,82 @@
|
|||||||
|
package com.cool.store.enums.video;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* video status
|
||||||
|
*/
|
||||||
|
public enum UploadTypeEnum {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查项提交
|
||||||
|
*/
|
||||||
|
TB_DATA_STA_TABLE_COLUMN(1),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 巡店记录总结
|
||||||
|
*/
|
||||||
|
TB_PATROL_STORE_RECORD(2),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 工单创建
|
||||||
|
*/
|
||||||
|
QUESTION_CREATE(3),
|
||||||
|
|
||||||
|
/**
|
||||||
|
*工单处理审核提交
|
||||||
|
*/
|
||||||
|
QUESTION_SUMMIT(4),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 父工单创建
|
||||||
|
*/
|
||||||
|
QUESTION_PARENT_CREATE(5),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 店务提交
|
||||||
|
*/
|
||||||
|
STORE_WORK_SUBMIT(6),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 运营手册
|
||||||
|
*/
|
||||||
|
TASK_SOP_ADD(7),
|
||||||
|
|
||||||
|
DEVICE_CAPTURE(8),
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 巡店自定义检查项提交
|
||||||
|
*/
|
||||||
|
TB_DATA_DEF_TABLE_COLUMN(9),
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 督导自定义检查项提交
|
||||||
|
*/
|
||||||
|
SUPERVISION_DATA_DEF_TABLE_COLUMN(10),
|
||||||
|
|
||||||
|
ACTIVITY_COMMENT(11),
|
||||||
|
|
||||||
|
WEEKLY_NEWSPAPER_LIST(12),
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 陈列检查项提交
|
||||||
|
*/
|
||||||
|
TB_DISPLAY_TABLE_DATA_COLUMN(13),
|
||||||
|
/**
|
||||||
|
* 陈列检查内容提交
|
||||||
|
*/
|
||||||
|
TB_DISPLAY_TABLE_DATA_CONTENT(14),
|
||||||
|
;
|
||||||
|
|
||||||
|
|
||||||
|
private final Integer value;
|
||||||
|
|
||||||
|
UploadTypeEnum(Integer value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getValue() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package com.cool.store.utils.vod;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Joshua on 2017/9/28 15:50
|
||||||
|
*/
|
||||||
|
public class AliResponseUtil {
|
||||||
|
|
||||||
|
public static String GetPostBody(InputStream is, int contentLen) {
|
||||||
|
if (contentLen > 0) {
|
||||||
|
int readLen = 0;
|
||||||
|
int readLengthThisTime = 0;
|
||||||
|
byte[] message = new byte[contentLen];
|
||||||
|
try {
|
||||||
|
while (readLen != contentLen) {
|
||||||
|
readLengthThisTime = is.read(message, readLen, contentLen - readLen);
|
||||||
|
if (readLengthThisTime == -1) {// Should not happen.
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
readLen += readLengthThisTime;
|
||||||
|
}
|
||||||
|
return new String(message);
|
||||||
|
} catch (IOException e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Map<String, String> convert(Map<String, String[]> requestParams) throws UnsupportedEncodingException {
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
for (String name : requestParams.keySet()) {
|
||||||
|
String[] values = (String[]) requestParams.get(name);
|
||||||
|
String valueStr = "";
|
||||||
|
for (int i = 0; i < values.length; i++) {
|
||||||
|
valueStr = (i == values.length - 1) ? valueStr + values[i]
|
||||||
|
: valueStr + values[i] + ",";
|
||||||
|
}
|
||||||
|
//乱码解决,这段代码在出现乱码时使用
|
||||||
|
valueStr = new String(valueStr.getBytes("ISO-8859-1"), "utf-8");
|
||||||
|
params.put(name, valueStr);
|
||||||
|
}
|
||||||
|
return params;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,209 @@
|
|||||||
|
package com.cool.store.utils.vod;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Joshua on 2017/9/28 13:06
|
||||||
|
*/
|
||||||
|
public class CallbackRequest {
|
||||||
|
private String EventType;
|
||||||
|
private String VideoId;
|
||||||
|
private String MediaId;
|
||||||
|
private String Status;
|
||||||
|
private String Bitrate;//视频流码率,单位Kbps
|
||||||
|
private String Definition;//视频流清晰度定义, 取值:FD(流畅),LD(标清),SD(高清),HD(超清),OD(原画),2K(2K),4K(4K)
|
||||||
|
private Float Duration;//视频流长度,单位秒
|
||||||
|
private Boolean Encrypt;//视频流是否加密流
|
||||||
|
private String ErrorCode;//视频流转码出错的时候,会有该字段表示出错代码
|
||||||
|
private String ErrorMessage;// 视频流转码出错的时候,会有该字段表示出错信息
|
||||||
|
private String FileUrl;//视频流的播放地址,不带鉴权的auth_key,如果开启了URL鉴权,则需要自己生成auth_key才能访问
|
||||||
|
private String Format;//视频流格式,取值:mp4, m3u8
|
||||||
|
private String Fps;//视频流帧率,每秒多少帧
|
||||||
|
private Long Height;// 视频流高度,单位px
|
||||||
|
private Long Size;// 视频流大小,单位Byte
|
||||||
|
private Long Width;// 视频流宽度,单位px
|
||||||
|
private List<CallbackStreamInfo> StreamInfos;
|
||||||
|
private String CoverUrl;//封面图片地址,若未设置封面,则取第一张截图为封面
|
||||||
|
private String[] Snapshots;// 截图地址列表
|
||||||
|
|
||||||
|
private String Data;
|
||||||
|
|
||||||
|
private String CreationTime; //人工审核时间
|
||||||
|
private String AuditStatus; //人工审核的结果
|
||||||
|
|
||||||
|
public String getEventType() {
|
||||||
|
return EventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEventType(String eventType) {
|
||||||
|
EventType = eventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getVideoId() {
|
||||||
|
return VideoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVideoId(String videoId) {
|
||||||
|
VideoId = videoId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
Status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBitrate() {
|
||||||
|
return Bitrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBitrate(String bitrate) {
|
||||||
|
Bitrate = bitrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefinition() {
|
||||||
|
return Definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(String definition) {
|
||||||
|
Definition = definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getDuration() {
|
||||||
|
return Duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(Float duration) {
|
||||||
|
Duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getEncrypt() {
|
||||||
|
return Encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncrypt(Boolean encrypt) {
|
||||||
|
Encrypt = encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorCode() {
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorCode(String errorCode) {
|
||||||
|
ErrorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return ErrorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorMessage(String errorMessage) {
|
||||||
|
ErrorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileUrl() {
|
||||||
|
return FileUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileUrl(String fileUrl) {
|
||||||
|
FileUrl = fileUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFormat() {
|
||||||
|
return Format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFormat(String format) {
|
||||||
|
Format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFps() {
|
||||||
|
return Fps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFps(String fps) {
|
||||||
|
Fps = fps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getHeight() {
|
||||||
|
return Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeight(Long height) {
|
||||||
|
Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSize() {
|
||||||
|
return Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(Long size) {
|
||||||
|
Size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getWidth() {
|
||||||
|
return Width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(Long width) {
|
||||||
|
Width = width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<CallbackStreamInfo> getStreamInfos() {
|
||||||
|
return StreamInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStreamInfos(List<CallbackStreamInfo> streamInfos) {
|
||||||
|
StreamInfos = streamInfos;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCoverUrl() {
|
||||||
|
return CoverUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCoverUrl(String coverUrl) {
|
||||||
|
CoverUrl = coverUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String[] getSnapshots() {
|
||||||
|
return Snapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSnapshots(String[] snapshots) {
|
||||||
|
Snapshots = snapshots;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getData() {
|
||||||
|
return Data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setData(String data) {
|
||||||
|
Data = data;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getCreationTime() {
|
||||||
|
return CreationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCreationTime(String creationTime) {
|
||||||
|
CreationTime = creationTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getAuditStatus() {
|
||||||
|
return AuditStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAuditStatus(String auditStatus) {
|
||||||
|
AuditStatus = auditStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMediaId() {
|
||||||
|
return MediaId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMediaId(String mediaId) {
|
||||||
|
MediaId = mediaId;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package com.cool.store.utils.vod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Joshua on 2017/9/28 13:09
|
||||||
|
*/
|
||||||
|
public class CallbackStreamInfo {
|
||||||
|
private String Status;// 视频流转码状态,取值:success(成功),fail(失败)
|
||||||
|
private Float Bitrate;// 视频流码率,单位Kbps
|
||||||
|
private String Definition;// 视频流清晰度定义, 取值:FD(流畅),LD(标清),SD(高清),HD(超清),OD(原画),2K(2K),4K(4K)
|
||||||
|
private Float Duration;// 视频流长度,单位秒
|
||||||
|
private Boolean Encrypt;// 视频流是否加密流
|
||||||
|
private String ErrorCode;// 视频流转码出错的时候,会有该字段表示出错代码
|
||||||
|
private String ErrorMessage;// 视频流转码出错的时候,会有该字段表示出错信息
|
||||||
|
private String FileUrl;// 视频流的播放地址,不带鉴权的auth_key,如果开启了播放鉴权,此地址会无法访问
|
||||||
|
private String Format;// 视频流格式,取值:mp4, m3u8
|
||||||
|
private Float Fps;// 视频流帧率,每秒多少帧
|
||||||
|
private Long Height;// 视频流高度,单位px
|
||||||
|
private Long Size;// 视频流大小,单位Byte
|
||||||
|
private Long Width;// 视频流宽度,单位px
|
||||||
|
|
||||||
|
public String getStatus() {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStatus(String status) {
|
||||||
|
Status = status;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getBitrate() {
|
||||||
|
return Bitrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBitrate(Float bitrate) {
|
||||||
|
Bitrate = bitrate;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getDefinition() {
|
||||||
|
return Definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDefinition(String definition) {
|
||||||
|
Definition = definition;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getDuration() {
|
||||||
|
return Duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDuration(Float duration) {
|
||||||
|
Duration = duration;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean getEncrypt() {
|
||||||
|
return Encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setEncrypt(Boolean encrypt) {
|
||||||
|
Encrypt = encrypt;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorCode() {
|
||||||
|
return ErrorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorCode(String errorCode) {
|
||||||
|
ErrorCode = errorCode;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getErrorMessage() {
|
||||||
|
return ErrorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setErrorMessage(String errorMessage) {
|
||||||
|
ErrorMessage = errorMessage;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFileUrl() {
|
||||||
|
return FileUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFileUrl(String fileUrl) {
|
||||||
|
FileUrl = fileUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFormat() {
|
||||||
|
return Format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFormat(String format) {
|
||||||
|
Format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Float getFps() {
|
||||||
|
return Fps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFps(Float fps) {
|
||||||
|
Fps = fps;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getHeight() {
|
||||||
|
return Height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHeight(Long height) {
|
||||||
|
Height = height;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getSize() {
|
||||||
|
return Size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSize(Long size) {
|
||||||
|
Size = size;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Long getWidth() {
|
||||||
|
return Width;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWidth(Long width) {
|
||||||
|
Width = width;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,29 @@
|
|||||||
|
package com.cool.store.utils.vod;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Joshua on 2017/9/28 13:41
|
||||||
|
*/
|
||||||
|
public class EventType {
|
||||||
|
/**
|
||||||
|
* 视频上传完成
|
||||||
|
*/
|
||||||
|
public static final String FileUploadComplete = "FileUploadComplete";
|
||||||
|
/**
|
||||||
|
* 视频截图完成
|
||||||
|
*/
|
||||||
|
public static final String SnapshotComplete = "SnapshotComplete";
|
||||||
|
/**
|
||||||
|
* 视频单个清晰度转码完成
|
||||||
|
*/
|
||||||
|
public static final String StreamTranscodeComplete = "StreamTranscodeComplete";
|
||||||
|
/**
|
||||||
|
* 视频全部清晰度转码完成
|
||||||
|
*/
|
||||||
|
public static final String TranscodeComplete = "TranscodeComplete";
|
||||||
|
/**
|
||||||
|
* 智能审核
|
||||||
|
*/
|
||||||
|
public static final String AIMediaAuditComplete = "AIMediaAuditComplete";
|
||||||
|
|
||||||
|
public static final String CreateAuditComplete = "CreateAuditComplete";
|
||||||
|
}
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
package com.cool.store.utils.vod;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenyupeng
|
||||||
|
* @since 2021/10/11
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmallVideoParam {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 企业id
|
||||||
|
*/
|
||||||
|
private String enterpriseId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务id
|
||||||
|
*/
|
||||||
|
private Long businessId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转码视频videoId
|
||||||
|
*/
|
||||||
|
private String videoId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* 上传类型
|
||||||
|
*/
|
||||||
|
private Integer uploadType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传时间
|
||||||
|
*/
|
||||||
|
private Date uploadTime;
|
||||||
|
}
|
||||||
@@ -0,0 +1,32 @@
|
|||||||
|
package com.cool.store.utils.vod;
|
||||||
|
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.annotation.JSONField;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @Title UserData
|
||||||
|
* @Description vod服务UserData参数
|
||||||
|
* @Author zhucg
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class UserData {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 回调设置
|
||||||
|
*/
|
||||||
|
@JSONField(name = "MessageCallback")
|
||||||
|
private MessageCallback messageCallback;
|
||||||
|
|
||||||
|
public void setCallBack(String callBackUrl) {
|
||||||
|
this.messageCallback = new MessageCallback();
|
||||||
|
this.messageCallback.setCallbackURL(callBackUrl);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class MessageCallback {
|
||||||
|
|
||||||
|
@JSONField(name = "CallbackURL")
|
||||||
|
private String callbackURL;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,60 @@
|
|||||||
|
package com.cool.store.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传的视频
|
||||||
|
*
|
||||||
|
* @author chenyupeng
|
||||||
|
* @since 2021/10/9
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmallVideoDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频id
|
||||||
|
*/
|
||||||
|
private String videoId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频url
|
||||||
|
*/
|
||||||
|
private String videoUrl;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 原视频url
|
||||||
|
*/
|
||||||
|
private String videoUrlBefore;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频截图封面
|
||||||
|
*/
|
||||||
|
private String videoSnapshot;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频大小
|
||||||
|
*/
|
||||||
|
private Long size;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转码状态
|
||||||
|
* @see com.coolcollege.intelligent.common.enums.video.ResourceStatusEnum
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传是否完成
|
||||||
|
*/
|
||||||
|
private boolean uploadStatus = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 截图是否完成
|
||||||
|
*/
|
||||||
|
private boolean snapShotStatus = false;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 转码是否完成
|
||||||
|
*/
|
||||||
|
private boolean transCodeStatus = false;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.cool.store.dto;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author chenyupeng
|
||||||
|
* @since 2021/10/12
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class SmallVideoInfoDTO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 视频集合
|
||||||
|
*/
|
||||||
|
private List<SmallVideoDTO> videoList;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 音频合计
|
||||||
|
*/
|
||||||
|
private List<String> soundRecordingList;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
package com.cool.store.service;
|
||||||
|
|
||||||
|
import com.cool.store.utils.vod.CallbackRequest;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author byd
|
||||||
|
* @date 2024-05-07 19:27
|
||||||
|
*/
|
||||||
|
public interface VodService {
|
||||||
|
|
||||||
|
void callback(CallbackRequest request);
|
||||||
|
}
|
||||||
@@ -0,0 +1,199 @@
|
|||||||
|
package com.cool.store.service.impl;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.cool.store.constants.CommonConstants;
|
||||||
|
import com.cool.store.constants.RedisConstant;
|
||||||
|
import com.cool.store.dao.AssessmentDataDAO;
|
||||||
|
import com.cool.store.dto.SmallVideoDTO;
|
||||||
|
import com.cool.store.dto.SmallVideoInfoDTO;
|
||||||
|
import com.cool.store.entity.AssessmentDataDO;
|
||||||
|
import com.cool.store.enums.video.ResourceStatusEnum;
|
||||||
|
import com.cool.store.enums.video.UploadTypeEnum;
|
||||||
|
import com.cool.store.service.VodService;
|
||||||
|
import com.cool.store.utils.RedisUtilPool;
|
||||||
|
import com.cool.store.utils.vod.CallbackRequest;
|
||||||
|
import com.cool.store.utils.vod.CallbackStreamInfo;
|
||||||
|
import com.cool.store.utils.vod.EventType;
|
||||||
|
import com.cool.store.utils.vod.SmallVideoParam;
|
||||||
|
import com.google.common.io.Files;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.apache.commons.collections4.CollectionUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.BeanUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import javax.annotation.Resource;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author byd
|
||||||
|
* @date 2024-05-07 19:28
|
||||||
|
*/
|
||||||
|
@Slf4j
|
||||||
|
@Service
|
||||||
|
public class VodServiceImpl implements VodService {
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private RedisUtilPool redisUtilPool;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AssessmentDataDAO assessmentDataDAO;
|
||||||
|
|
||||||
|
public static final Integer EXPIRE_TIME = 3600 * 72;
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void callback(CallbackRequest request) {
|
||||||
|
log.info("CallbackRequest:{}", JSONObject.toJSONString(request));
|
||||||
|
//未完成转码的视频
|
||||||
|
String videoId = request.getVideoId();
|
||||||
|
|
||||||
|
String eventType = request.getEventType();
|
||||||
|
String newVideoInfo = "";
|
||||||
|
String callbackCache = redisUtilPool.getString(RedisConstant.VIDEO_CALLBACK_CACHE + videoId);
|
||||||
|
SmallVideoDTO smallVideoDTO;
|
||||||
|
if (StringUtils.isNotBlank(callbackCache)) {
|
||||||
|
smallVideoDTO = JSONObject.parseObject(callbackCache, SmallVideoDTO.class);
|
||||||
|
} else {
|
||||||
|
smallVideoDTO = new SmallVideoDTO();
|
||||||
|
}
|
||||||
|
log.info("smallVideoDTO:{}", JSONObject.toJSONString(smallVideoDTO));
|
||||||
|
smallVideoDTO.setSize(request.getSize());
|
||||||
|
smallVideoDTO.setVideoId(videoId);
|
||||||
|
switch (eventType) {
|
||||||
|
//视频上传完成
|
||||||
|
case EventType.FileUploadComplete:
|
||||||
|
smallVideoDTO.setStatus(ResourceStatusEnum.TRANSCODING.getValue());
|
||||||
|
smallVideoDTO.setVideoUrlBefore(request.getFileUrl());
|
||||||
|
log.info("视频原始地址:{}", request.getFileUrl());
|
||||||
|
//mp4不转码处理
|
||||||
|
if (Files.getFileExtension(request.getFileUrl()).equalsIgnoreCase(CommonConstants.TRANSCODE_VIDEO)) {
|
||||||
|
if (CommonConstants.SUCCESS_STR.equalsIgnoreCase(request.getStatus())) {
|
||||||
|
smallVideoDTO.setVideoUrl(request.getFileUrl());
|
||||||
|
} else {
|
||||||
|
smallVideoDTO.setStatus(ResourceStatusEnum.TRANSCODE_FAILED.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
smallVideoDTO.setUploadStatus(true);
|
||||||
|
newVideoInfo = JSONObject.toJSONString(smallVideoDTO);
|
||||||
|
//过期时间为一周
|
||||||
|
redisUtilPool.setString(RedisConstant.VIDEO_CALLBACK_CACHE + videoId, newVideoInfo, EXPIRE_TIME);
|
||||||
|
break;
|
||||||
|
//视频截图完成
|
||||||
|
case EventType.SnapshotComplete:
|
||||||
|
// 视频截图完成,且课件状态在转码完成之前时,更新状态为截图完成
|
||||||
|
if (smallVideoDTO.getStatus() == null || smallVideoDTO.getStatus() < ResourceStatusEnum.TRANSCODE_FINISH.getValue()) {
|
||||||
|
smallVideoDTO.setStatus(ResourceStatusEnum.SCREENSHOT_FINISHED.getValue());
|
||||||
|
}
|
||||||
|
//视频封面
|
||||||
|
smallVideoDTO.setVideoSnapshot(request.getCoverUrl());
|
||||||
|
|
||||||
|
//如果上传的就是mp4,就不进行转码,截图完成就把状态改为转码完成
|
||||||
|
if (StringUtils.isNotBlank(smallVideoDTO.getVideoUrlBefore())
|
||||||
|
&& Files.getFileExtension(smallVideoDTO.getVideoUrlBefore()).equalsIgnoreCase(CommonConstants.TRANSCODE_VIDEO)
|
||||||
|
&& !smallVideoDTO.getStatus().equals(ResourceStatusEnum.TRANSCODE_FAILED.getValue())) {
|
||||||
|
|
||||||
|
smallVideoDTO.setStatus(ResourceStatusEnum.TRANSCODE_FINISH.getValue());
|
||||||
|
smallVideoDTO.setTransCodeStatus(true);
|
||||||
|
}
|
||||||
|
smallVideoDTO.setSnapShotStatus(true);
|
||||||
|
newVideoInfo = JSONObject.toJSONString(smallVideoDTO);
|
||||||
|
|
||||||
|
//过期时间为一周
|
||||||
|
redisUtilPool.setString(RedisConstant.VIDEO_CALLBACK_CACHE + videoId, newVideoInfo, EXPIRE_TIME);
|
||||||
|
break;
|
||||||
|
//视频全部清晰度转码完成
|
||||||
|
case EventType.TranscodeComplete:
|
||||||
|
if (CommonConstants.SUCCESS_STR.equalsIgnoreCase(request.getStatus())) {
|
||||||
|
smallVideoDTO.setTransCodeStatus(true);
|
||||||
|
smallVideoDTO.setStatus(ResourceStatusEnum.TRANSCODE_FINISH.getValue());
|
||||||
|
List<CallbackStreamInfo> streamInfoList = request.getStreamInfos();
|
||||||
|
for (CallbackStreamInfo streamInfo : streamInfoList) {
|
||||||
|
log.info("VodService callback playInfo.getFormat:{}", streamInfo.getFormat());
|
||||||
|
if (Objects.nonNull(smallVideoDTO.getStatus()) && smallVideoDTO.getStatus().intValue() != ResourceStatusEnum.TRANSCODE_FAILED.getValue()) {
|
||||||
|
smallVideoDTO.setVideoUrl(streamInfo.getFileUrl());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
smallVideoDTO.setStatus(ResourceStatusEnum.TRANSCODE_FAILED.getValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
log.info("视频转码完成,videoId:{}", videoId);
|
||||||
|
newVideoInfo = JSONObject.toJSONString(smallVideoDTO);
|
||||||
|
//过期时间为一周
|
||||||
|
redisUtilPool.setString(RedisConstant.VIDEO_CALLBACK_CACHE + videoId, newVideoInfo, EXPIRE_TIME);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
log.info("videoId:{},转码状态:{}", videoId, smallVideoDTO.getStatus());
|
||||||
|
//未完成转码处理
|
||||||
|
notCompleteCacheHandle(smallVideoDTO, videoId);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 如果前端提交的时候,视频还没有转码成功,会把videoId存入缓存,回调的时候再进行处理
|
||||||
|
*
|
||||||
|
* @param smallVideoDTO
|
||||||
|
* @param videoId
|
||||||
|
* @return void
|
||||||
|
* @author chenyupeng
|
||||||
|
* @date 2021/10/14
|
||||||
|
*/
|
||||||
|
public void notCompleteCacheHandle(SmallVideoDTO smallVideoDTO, String videoId) {
|
||||||
|
log.info("videoId:{}, smallVideoDTO:{}", videoId, JSONObject.toJSONString(smallVideoDTO));
|
||||||
|
//回调事件都完成才入库
|
||||||
|
if (!(smallVideoDTO.isUploadStatus() && smallVideoDTO.isSnapShotStatus() && smallVideoDTO.isTransCodeStatus())) {
|
||||||
|
log.info("回调事件都完成才入库videoId:{}", videoId);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
String notCompleteCache = redisUtilPool.hashGet(RedisConstant.VIDEO_NOT_COMPLETE_CACHE, videoId);
|
||||||
|
log.info("notCompleteCache:{}", notCompleteCache);
|
||||||
|
if (StringUtils.isNotBlank(notCompleteCache)) {
|
||||||
|
if (StringUtils.isNotBlank(smallVideoDTO.getVideoUrl())) {
|
||||||
|
smallVideoDTO.setVideoUrl(smallVideoDTO.getVideoUrl().replace("http://", "https://"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtils.isNotBlank(smallVideoDTO.getVideoUrlBefore())) {
|
||||||
|
smallVideoDTO.setVideoUrlBefore(smallVideoDTO.getVideoUrlBefore().replace("http://", "https://"));
|
||||||
|
}
|
||||||
|
SmallVideoParam smallVideoParam = JSONObject.parseObject(notCompleteCache, SmallVideoParam.class);
|
||||||
|
if (UploadTypeEnum.TB_DATA_STA_TABLE_COLUMN.getValue().equals(smallVideoParam.getUploadType())) {
|
||||||
|
//检查项提交
|
||||||
|
dealVideo(smallVideoDTO, smallVideoParam);
|
||||||
|
//保存完删除缓存
|
||||||
|
redisUtilPool.hashDel(RedisConstant.VIDEO_NOT_COMPLETE_CACHE, videoId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void dealVideo(SmallVideoDTO smallVideoDTO, SmallVideoParam smallVideoParam) {
|
||||||
|
|
||||||
|
AssessmentDataDO assessmentDataDO = assessmentDataDAO.selectByPrimaryKey(smallVideoParam.getBusinessId());
|
||||||
|
|
||||||
|
log.info("视频信息,checkVideo:{}", assessmentDataDO.getVideo());
|
||||||
|
assessmentDataDO.setVideo(transSmallVideoDTO(assessmentDataDO.getVideo(), smallVideoDTO));
|
||||||
|
assessmentDataDAO.updateByPrimaryKeySelective(assessmentDataDO);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String transSmallVideoDTO(String videoInfo, SmallVideoDTO smallVideoDto) {
|
||||||
|
|
||||||
|
log.info("transSmallVideoDTO,videoInfo:{},smallVideoDto:{}", videoInfo, smallVideoDto.toString());
|
||||||
|
SmallVideoInfoDTO smallVideoInfoDTO = JSONObject.parseObject(videoInfo, SmallVideoInfoDTO.class);
|
||||||
|
if (smallVideoInfoDTO == null) {
|
||||||
|
smallVideoInfoDTO = new SmallVideoInfoDTO();
|
||||||
|
}
|
||||||
|
if (CollectionUtils.isEmpty(smallVideoInfoDTO.getVideoList())) {
|
||||||
|
smallVideoInfoDTO.setVideoList(Collections.singletonList(smallVideoDto));
|
||||||
|
return JSONObject.toJSONString(smallVideoInfoDTO);
|
||||||
|
}
|
||||||
|
for (SmallVideoDTO smallVideo : smallVideoInfoDTO.getVideoList()) {
|
||||||
|
if (smallVideo.getVideoId() == null || StringUtils.equals(smallVideo.getVideoId(), smallVideoDto.getVideoId())) {
|
||||||
|
BeanUtils.copyProperties(smallVideoDto, smallVideo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return JSONObject.toJSONString(smallVideoInfoDTO);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@@ -48,6 +48,7 @@ public class TokenValidateFilter implements Filter {
|
|||||||
"/**/swagger*/**", "/**/webjars/**",
|
"/**/swagger*/**", "/**/webjars/**",
|
||||||
//腾讯音视频回调,单独做验签
|
//腾讯音视频回调,单独做验签
|
||||||
"/xfsg/pc/video/**",
|
"/xfsg/pc/video/**",
|
||||||
|
"/xfsg/pc/vod/callback",
|
||||||
"/xfsg/pc/sysRole/**",
|
"/xfsg/pc/sysRole/**",
|
||||||
"/xfsg/**/api/audit/result",
|
"/xfsg/**/api/audit/result",
|
||||||
"/xfsg/pc/video/**",
|
"/xfsg/pc/video/**",
|
||||||
|
|||||||
@@ -0,0 +1,46 @@
|
|||||||
|
package com.cool.store.controller.webb;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSON;
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.cool.store.service.VodService;
|
||||||
|
import com.cool.store.utils.vod.AliResponseUtil;
|
||||||
|
import com.cool.store.utils.vod.CallbackRequest;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author byd
|
||||||
|
* @date 2024-05-07 19:13
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("pc/vod")
|
||||||
|
@Api(tags = "视频回调接口")
|
||||||
|
@Slf4j
|
||||||
|
public class VodController {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private VodService vodService;
|
||||||
|
|
||||||
|
@RequestMapping("callback")
|
||||||
|
public JSONObject callback(HttpServletRequest request) throws IOException {
|
||||||
|
log.info("=================================");
|
||||||
|
log.info("VOD视频回调");
|
||||||
|
String cl = request.getHeader("content-length");
|
||||||
|
log.info("content-length:" + cl);
|
||||||
|
String vodCallbackBody = AliResponseUtil.GetPostBody(request.getInputStream(), Integer.parseInt(cl));
|
||||||
|
log.info("vodCallbackBody:" + vodCallbackBody);
|
||||||
|
CallbackRequest callback = JSON.parseObject(vodCallbackBody, CallbackRequest.class);
|
||||||
|
log.info("callback" + JSON.toJSONString(callback));
|
||||||
|
vodService.callback(callback);
|
||||||
|
log.info("=================================");
|
||||||
|
JSONObject jsonObject = new JSONObject();
|
||||||
|
jsonObject.put("Status", "OK");
|
||||||
|
return jsonObject;
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user