Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in / Register
Toggle navigation
Y
yzg-util
Project
Project
Details
Activity
Releases
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
YZG
yzg-util
Commits
8d83f8e9
Commit
8d83f8e9
authored
Nov 12, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
参数处理
parent
9cdff7e5
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
22 deletions
+43
-22
YzgFileServiceImpl.java
...n/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
+24
-22
MediaHelper.java
...image/src/main/java/com/yanzuoguang/util/MediaHelper.java
+19
-0
No files found.
yzg-util-file/src/main/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
View file @
8d83f8e9
package
com
.
yanzuoguang
.
cloud
.
file
;
package
com
.
yanzuoguang
.
cloud
.
file
;
import
com.yanzuoguang.cloud.file.vo.*
;
import
com.yanzuoguang.cloud.file.vo.*
;
import
com.yanzuoguang.util.MediaHelper
;
import
com.yanzuoguang.util.MediaParameter
;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.cache.MemoryCache
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.exception.CodeException
;
import
com.yanzuoguang.util.helper.DateHelper
;
import
com.yanzuoguang.util.helper.DateHelper
;
...
@@ -189,33 +191,33 @@ public class YzgFileServiceImpl implements YzgFileService {
...
@@ -189,33 +191,33 @@ public class YzgFileServiceImpl implements YzgFileService {
fileConfig
.
init
(
info
,
fromUrl
);
fileConfig
.
init
(
info
,
fromUrl
);
String
serverFullPath
=
fileConfig
.
getServerFullPath
(
fromUrl
);
String
serverFullPath
=
fileConfig
.
getServerFullPath
(
fromUrl
);
switch
(
info
.
getType
())
{
try
{
case
FileHelper
.
FILE_TYPE_AUDIO
:
{
switch
(
info
.
getType
())
{
FFmpegFrameGrabber
grabber
=
new
FFmpegFrameGrabber
(
serverFullPath
);
case
FileHelper
.
FILE_TYPE_AUDIO
:
{
info
.
setBitrate
(
Double
.
valueOf
(
grabber
.
getVideoBitrate
())
);
MediaParameter
parameter
=
MediaHelper
.
getGrabberParameter
(
serverFullPath
);
break
;
info
.
setBitrate
(
Double
.
valueOf
(
parameter
.
getAudioBitRate
()))
;
}
break
;
case
FileHelper
.
FILE_TYPE_VIDEO
:
{
}
FFmpegFrameGrabber
grabber
=
new
FFmpegFrameGrabber
(
serverFullPath
);
case
FileHelper
.
FILE_TYPE_VIDEO
:
{
info
.
setBitrate
(
Double
.
valueOf
(
grabber
.
getVideoBitrate
())
);
MediaParameter
parameter
=
MediaHelper
.
getGrabberParameter
(
serverFullPath
);
info
.
setWidth
(
Double
.
valueOf
(
grabber
.
getImageWidth
()));
info
.
setBitrate
(
Double
.
valueOf
(
parameter
.
getVideoBitRate
()));
info
.
setHeight
(
Double
.
valueOf
(
grabber
.
getImageHeight
()));
info
.
setWidth
(
Double
.
valueOf
(
parameter
.
getVideoWidth
()));
break
;
info
.
setHeight
(
Double
.
valueOf
(
parameter
.
getVideoHeight
()))
;
}
break
;
case
FileHelper
.
FILE_TYPE_IMAGE
:
{
}
try
{
case
FileHelper
.
FILE_TYPE_IMAGE
:
{
BufferedImage
sourceImg
=
ImageIO
.
read
(
new
FileInputStream
(
serverFullPath
));
BufferedImage
sourceImg
=
ImageIO
.
read
(
new
FileInputStream
(
serverFullPath
));
info
.
setWidth
(
Double
.
valueOf
(
sourceImg
.
getWidth
()));
info
.
setWidth
(
Double
.
valueOf
(
sourceImg
.
getWidth
()));
info
.
setHeight
(
Double
.
valueOf
(
sourceImg
.
getHeight
()));
info
.
setHeight
(
Double
.
valueOf
(
sourceImg
.
getHeight
()));
}
catch
(
IOException
e
)
{
break
;
throw
new
RuntimeException
(
e
);
}
case
FileHelper
.
FILE_TYPE_NONE
:
default
:
{
break
;
}
}
break
;
}
case
FileHelper
.
FILE_TYPE_NONE
:
default
:
{
break
;
}
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
}
return
info
;
return
info
;
}
}
...
...
yzg-util-image/src/main/java/com/yanzuoguang/util/MediaHelper.java
View file @
8d83f8e9
...
@@ -206,6 +206,25 @@ public class MediaHelper extends ImageHelper {
...
@@ -206,6 +206,25 @@ public class MediaHelper extends ImageHelper {
}
}
}
}
/**
* 获取视频缩略图
*
* @param filePath 视频路径
* @throws IOException
*/
public
static
MediaParameter
getGrabberParameter
(
String
filePath
)
throws
IOException
{
FFmpegFrameGrabber
grabber
=
new
FFmpegFrameGrabber
(
filePath
);
MediaParameter
parameter
=
new
MediaParameter
();
try
{
// 打开视频
grabber
.
start
();
parameter
.
init
(
grabber
);
}
finally
{
grabber
.
close
();
}
return
parameter
;
}
/**
/**
* 旋转图片
* 旋转图片
*
*
...
...
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