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
Show 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
;
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.exception.CodeException
;
import
com.yanzuoguang.util.helper.DateHelper
;
...
...
@@ -189,27 +191,24 @@ public class YzgFileServiceImpl implements YzgFileService {
fileConfig
.
init
(
info
,
fromUrl
);
String
serverFullPath
=
fileConfig
.
getServerFullPath
(
fromUrl
);
try
{
switch
(
info
.
getType
())
{
case
FileHelper
.
FILE_TYPE_AUDIO
:
{
FFmpegFrameGrabber
grabber
=
new
FFmpegFrameGrabb
er
(
serverFullPath
);
info
.
setBitrate
(
Double
.
valueOf
(
grabber
.
getVideoBitr
ate
()));
MediaParameter
parameter
=
MediaHelper
.
getGrabberParamet
er
(
serverFullPath
);
info
.
setBitrate
(
Double
.
valueOf
(
parameter
.
getAudioBitR
ate
()));
break
;
}
case
FileHelper
.
FILE_TYPE_VIDEO
:
{
FFmpegFrameGrabber
grabber
=
new
FFmpegFrameGrabb
er
(
serverFullPath
);
info
.
setBitrate
(
Double
.
valueOf
(
grabber
.
getVideoBitr
ate
()));
info
.
setWidth
(
Double
.
valueOf
(
grabber
.
getImage
Width
()));
info
.
setHeight
(
Double
.
valueOf
(
grabber
.
getImage
Height
()));
MediaParameter
parameter
=
MediaHelper
.
getGrabberParamet
er
(
serverFullPath
);
info
.
setBitrate
(
Double
.
valueOf
(
parameter
.
getVideoBitR
ate
()));
info
.
setWidth
(
Double
.
valueOf
(
parameter
.
getVideo
Width
()));
info
.
setHeight
(
Double
.
valueOf
(
parameter
.
getVideo
Height
()));
break
;
}
case
FileHelper
.
FILE_TYPE_IMAGE
:
{
try
{
BufferedImage
sourceImg
=
ImageIO
.
read
(
new
FileInputStream
(
serverFullPath
));
info
.
setWidth
(
Double
.
valueOf
(
sourceImg
.
getWidth
()));
info
.
setHeight
(
Double
.
valueOf
(
sourceImg
.
getHeight
()));
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
break
;
}
case
FileHelper
.
FILE_TYPE_NONE
:
...
...
@@ -217,6 +216,9 @@ public class YzgFileServiceImpl implements YzgFileService {
break
;
}
}
}
catch
(
IOException
e
)
{
throw
new
RuntimeException
(
e
);
}
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 {
}
}
/**
* 获取视频缩略图
*
* @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