Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
member-api
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
曲欣亮
member-api
Commits
e9e40a82
Commit
e9e40a82
authored
Feb 13, 2019
by
张永
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
调整 阿里云接口,创建转码模板
parent
3f52e3fb
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
592 additions
and
401 deletions
+592
-401
AliyunApiController.java
...main/java/com/egolm/film/api/web/AliyunApiController.java
+114
-2
AliyunSign.java
src/main/java/com/egolm/film/util/AliyunSign.java
+246
-169
AliyunUtil.java
src/main/java/com/egolm/film/util/AliyunUtil.java
+228
-228
application-dev.properties
src/main/resources/application-dev.properties
+2
-1
application-pro.properties
src/main/resources/application-pro.properties
+2
-1
No files found.
src/main/java/com/egolm/film/api/web/AliyunApiController.java
View file @
e9e40a82
...
...
@@ -12,12 +12,16 @@ import org.springframework.web.bind.annotation.RequestMapping;
import
org.springframework.web.bind.annotation.RequestMethod
;
import
org.springframework.web.bind.annotation.ResponseBody
;
import
com.alibaba.fastjson.JSONArray
;
import
com.alibaba.fastjson.JSONObject
;
import
com.aliyuncs.vod.model.v20170321.CreateUploadVideoResponse
;
import
com.aliyuncs.vod.model.v20170321.GetVideoPlayAuthResponse
;
import
com.aliyuncs.vod.model.v20170321.RefreshUploadVideoResponse
;
import
com.egolm.common.HttpUtil
;
import
com.egolm.common.StringUtil
;
import
com.egolm.common.bean.Rjx
;
import
com.egolm.film.api.service.Messages
;
import
com.egolm.film.util.AliyunSign
;
import
com.egolm.film.util.AliyunUtil
;
import
io.swagger.annotations.Api
;
...
...
@@ -36,6 +40,10 @@ public class AliyunApiController {
@Value
(
"${aliyun.sts.accessKeySecret}"
)
private
String
accessKeySecret
;
@Value
(
"${aliyun.video.templateId}"
)
private
String
templateId
;
@Autowired
private
Messages
messages
;
...
...
@@ -74,7 +82,7 @@ public class AliyunApiController {
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
())
.
set
(
"UploadAddress"
,
response
.
getUploadAddress
())
.
set
(
"VideoId"
,
response
.
getVideoId
());
.
set
(
"VideoId"
,
response
.
getVideoId
())
.
set
(
"templateId"
,
templateId
)
;
}
...
...
@@ -93,7 +101,7 @@ public class AliyunApiController {
AliyunUtil
aliyunUtil
=
new
AliyunUtil
(
accessKeyId
,
accessKeySecret
);
RefreshUploadVideoResponse
response
=
aliyunUtil
.
refreshUploadVideo
(
videoId
);
if
(
response
!=
null
)
{
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
()).
set
(
"UploadAddress"
,
response
.
getUploadAddress
());
return
Rjx
.
jsonOk
().
set
(
"RequestId"
,
response
.
getRequestId
()).
set
(
"UploadAuth"
,
response
.
getUploadAuth
()).
set
(
"UploadAddress"
,
response
.
getUploadAddress
())
.
set
(
"templateId"
,
templateId
)
;
}
else
{
return
Rjx
.
jsonErr
().
setCode
(-
1
).
setMessage
(
"InvalidVideo.NotFound : The video does not exist."
);
}
...
...
@@ -129,5 +137,109 @@ public class AliyunApiController {
}
}
/**
* https://help.aliyun.com/document_detail/52839.html?spm=a2c4g.11186623.2.16.56da9028Qxc5wl#TranscodeTemplate
* @Title: transcode
* @Description: TODO(这里用一句话描述这个方法的作用)
* @param: @param request
* @param: @return
* @return: Object
* @throws
*/
@ResponseBody
@ApiOperation
(
"新增视频转码模板"
)
@ApiImplicitParams
({
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"templateName"
,
dataType
=
"String"
,
required
=
true
,
value
=
"转码组名称"
,
defaultValue
=
""
),
@ApiImplicitParam
(
paramType
=
"query"
,
name
=
"watermarkIds"
,
dataType
=
"String"
,
required
=
true
,
value
=
"水印ID(值来源于水印管理)"
,
defaultValue
=
""
),
})
@RequestMapping
(
value
=
"/addTranscodeTemplate"
,
method
=
RequestMethod
.
GET
)
public
Object
addTranscodeTemplate
(
HttpServletRequest
request
)
{
String
templateName
=
request
.
getParameter
(
"templateName"
);
String
watermarkIds
=
request
.
getParameter
(
"watermarkIds"
);
if
(!
StringUtil
.
isNotEmpty
(
templateName
,
watermarkIds
))
{
return
Rjx
.
jsonErr
().
setCode
(-
1
).
setMessage
(
"参数不能为空"
);
}
//模板参数信息
JSONObject
videoObj
=
new
JSONObject
();
videoObj
.
put
(
"Codec"
,
"H.264"
);
videoObj
.
put
(
"Bitrate"
,
"900"
);
videoObj
.
put
(
"Width"
,
"960"
);
videoObj
.
put
(
"Height"
,
"540"
);
videoObj
.
put
(
"Remove"
,
false
);
videoObj
.
put
(
"Fps"
,
"25"
);
videoObj
.
put
(
"Gop"
,
"250"
);
JSONObject
audioObj
=
new
JSONObject
();
audioObj
.
put
(
"Codec"
,
"AAC"
);
audioObj
.
put
(
"Bitrate"
,
"96"
);
audioObj
.
put
(
"Remove"
,
false
);
audioObj
.
put
(
"Samplerate"
,
"44100"
);
audioObj
.
put
(
"Channels"
,
"2"
);
JSONObject
containerObj
=
new
JSONObject
();
containerObj
.
put
(
"Format"
,
"m3u8"
);
//填m3u8 生成的格式就为 hls
JSONObject
muxConfigObj
=
new
JSONObject
();
JSONObject
segmentObj
=
new
JSONObject
();
segmentObj
.
put
(
"Duration"
,
"10"
);
muxConfigObj
.
put
(
"Segment"
,
segmentObj
);
JSONObject
encryptSettingObj
=
new
JSONObject
();
encryptSettingObj
.
put
(
"EncryptType"
,
"Private"
);
JSONObject
packageSettingObj
=
new
JSONObject
();
packageSettingObj
.
put
(
"PackageType"
,
"HLSPackage"
);
JSONObject
packageConfigObj
=
new
JSONObject
();
packageConfigObj
.
put
(
"BandWidth"
,
"900000"
);
packageSettingObj
.
put
(
"PackageConfig"
,
packageConfigObj
);
JSONObject
obj
=
new
JSONObject
();
obj
.
put
(
"Video"
,
videoObj
);
obj
.
put
(
"Audio"
,
audioObj
);
obj
.
put
(
"Container"
,
containerObj
);
obj
.
put
(
"MuxConfig"
,
muxConfigObj
);
obj
.
put
(
"EncryptSetting"
,
encryptSettingObj
);
//obj.put("PackageSetting", packageSettingObj);
obj
.
put
(
"WatermarkIds"
,
watermarkIds
);
obj
.
put
(
"Definition"
,
"SD"
);
//原画
obj
.
put
(
"TemplateName"
,
templateName
);
JSONArray
array
=
new
JSONArray
();
array
.
add
(
obj
);
//生成私有参数,不同API需要修改
Map
<
String
,
String
>
privateParams
=
new
HashMap
<
String
,
String
>();
privateParams
.
put
(
"Action"
,
"AddTranscodeTemplateGroup"
);
privateParams
.
put
(
"Name"
,
templateName
);
privateParams
.
put
(
"TranscodeTemplateList"
,
array
.
toJSONString
());
System
.
out
.
println
(
array
.
toJSONString
());
//生成公共参数,不需要修改
Map
<
String
,
String
>
publicParams
=
AliyunSign
.
generatePublicParamters
();
//生成OpenAPI地址,不需要修改
String
URL
=
AliyunSign
.
generateOpenAPIURL
(
publicParams
,
privateParams
);
//发送HTTP GET 请求
String
result
=
HttpUtil
.
get
(
URL
);
System
.
out
.
println
(
result
);
return
result
;
}
}
src/main/java/com/egolm/film/util/AliyunSign.java
View file @
e9e40a82
This diff is collapsed.
Click to expand it.
src/main/java/com/egolm/film/util/AliyunUtil.java
View file @
e9e40a82
This diff is collapsed.
Click to expand it.
src/main/resources/application-dev.properties
View file @
e9e40a82
...
...
@@ -36,5 +36,6 @@ spring.datasource.min-idle=10
aliyun.sts.accessKeyId
=
LTAIOtHCCpDLXYp8
aliyun.sts.accessKeySecret
=
9XTHW7P9TTRvCsBHBSclOue2tdWOoa
#\u89C6\u9891\u8F6C\u7801ID
aliyun.video.templateId
=
d9f4a79cba14ce4cbc98d6516d35bf37
opt.project.type
=
1
\ No newline at end of file
src/main/resources/application-pro.properties
View file @
e9e40a82
...
...
@@ -35,5 +35,6 @@ spring.datasource.min-idle=10
aliyun.sts.accessKeyId
=
LTAIOtHCCpDLXYp8
aliyun.sts.accessKeySecret
=
9XTHW7P9TTRvCsBHBSclOue2tdWOoa
#\u89C6\u9891\u8F6C\u7801ID
aliyun.video.templateId
=
d9f4a79cba14ce4cbc98d6516d35bf37
opt.project.type
=
1
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment