Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Q
qk_backend
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
quanku
qk_backend
Commits
636bde12
Commit
636bde12
authored
Aug 15, 2023
by
shiyu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
媒体工具类
parent
436e4f4a
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
0 deletions
+46
-0
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
+46
-0
No files found.
ch-core/src/main/java/com/wwdz/ch/core/util/MediaUtil.java
0 → 100644
View file @
636bde12
package
com.wwdz.ch.core.util
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.IOException
;
import
java.io.InputStream
;
public
class
MediaUtil
{
private
static
final
Logger
logger
=
LoggerFactory
.
getLogger
(
MediaUtil
.
class
);
//截取视频第一帧图片
private
final
static
String
CUT_VEDIO_SUFFIX
=
"?vframe/jpg/offset/0"
;
/**
* 七牛截取视频第一帧
* @param vedioUrl
* @return
*/
public
static
String
getImageByCutVedio
(
String
vedioUrl
)
{
return
vedioUrl
+
CUT_VEDIO_SUFFIX
;
}
/**
* 将BufferedImage转换为InputStream
*
* @param image 数据源
* @param type 图片格式(eg:jpg、png)
* @return
*/
private
static
InputStream
bufferedImageToInputStream
(
BufferedImage
image
,
String
type
)
{
try
(
ByteArrayOutputStream
os
=
new
ByteArrayOutputStream
())
{
ImageIO
.
write
(
image
,
type
,
os
);
return
new
ByteArrayInputStream
(
os
.
toByteArray
());
}
catch
(
IOException
e
)
{
logger
.
error
(
"bufferedImageToInputStream 出错,原因: {}"
,
e
);
}
return
null
;
}
}
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