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
9cdff7e5
Commit
9cdff7e5
authored
Nov 12, 2020
by
yanzg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
文件处理
parent
9f467414
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
67 additions
and
30 deletions
+67
-30
YzgFileVideoImageInfoVo.java
...om/yanzuoguang/cloud/file/vo/YzgFileVideoImageInfoVo.java
+13
-13
YzgFileVideoImageItemReqVo.java
...yanzuoguang/cloud/file/vo/YzgFileVideoImageItemReqVo.java
+16
-16
YzgFileServiceImpl.java
...n/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
+38
-1
No files found.
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/file/vo/YzgFileVideoImageInfoVo.java
View file @
9cdff7e5
...
...
@@ -13,13 +13,13 @@ public class YzgFileVideoImageInfoVo extends YzgFileBaseVo {
* 分辨率x,如: 1920*1080中的1920.
*/
@ApiModelProperty
(
notes
=
"分辨率x,如: 1920*1080中的1920."
)
private
Double
x
;
private
Double
width
;
/**
* 分辨率y,如: 1920*1080中的1080.
*/
@ApiModelProperty
(
notes
=
"分辨率y,如: 1920*1080中的1080."
)
private
Double
y
;
private
Double
height
;
/**
* 质量
...
...
@@ -30,27 +30,27 @@ public class YzgFileVideoImageInfoVo extends YzgFileBaseVo {
public
YzgFileVideoImageInfoVo
()
{
}
public
YzgFileVideoImageInfoVo
(
String
server
,
String
display
,
long
size
,
String
mime
,
int
type
,
double
x
,
double
y
,
double
bitrate
)
{
public
YzgFileVideoImageInfoVo
(
String
server
,
String
display
,
long
size
,
String
mime
,
int
type
,
double
width
,
double
height
,
double
bitrate
)
{
super
(
server
,
display
,
size
,
mime
,
type
);
this
.
x
=
x
;
this
.
y
=
y
;
this
.
width
=
width
;
this
.
height
=
height
;
this
.
bitrate
=
bitrate
;
}
public
Double
get
X
()
{
return
x
;
public
Double
get
Width
()
{
return
width
;
}
public
void
set
X
(
Double
x
)
{
this
.
x
=
x
;
public
void
set
Width
(
Double
width
)
{
this
.
width
=
width
;
}
public
Double
get
Y
()
{
return
y
;
public
Double
get
Height
()
{
return
height
;
}
public
void
set
Y
(
Double
y
)
{
this
.
y
=
y
;
public
void
set
Height
(
Double
height
)
{
this
.
height
=
height
;
}
public
Double
getBitrate
()
{
...
...
yzg-util-cloud/src/main/java/com/yanzuoguang/cloud/file/vo/YzgFileVideoImageItemReqVo.java
View file @
9cdff7e5
...
...
@@ -35,28 +35,28 @@ public class YzgFileVideoImageItemReqVo extends BaseVo {
private
double
quote
=
1
D
;
@ApiModelProperty
(
notes
=
"分辨率x,如: 1920*1080中的1920."
)
private
double
x
=
0
;
private
double
width
=
0
;
@ApiModelProperty
(
notes
=
"分辨率x,如: 1920*1080中的1080."
)
private
double
y
=
0
;
private
double
height
=
0
;
public
YzgFileVideoImageItemReqVo
()
{
}
private
YzgFileVideoImageItemReqVo
(
double
size
,
double
quote
,
double
x
,
double
y
)
{
private
YzgFileVideoImageItemReqVo
(
double
size
,
double
quote
,
double
width
,
double
height
)
{
this
.
size
=
size
;
this
.
quote
=
quote
;
this
.
x
=
x
;
this
.
y
=
y
;
this
.
width
=
width
;
this
.
height
=
height
;
}
public
YzgFileVideoImageItemReqVo
(
String
toFile
,
@NotNull
YzgFileVideoImageItemReqVo
from
)
{
this
(
from
.
size
,
from
.
quote
,
from
.
x
,
from
.
y
);
this
(
from
.
size
,
from
.
quote
,
from
.
width
,
from
.
height
);
this
.
toFile
=
toFile
;
}
public
YzgFileVideoImageItemReqVo
(
String
toFile
,
double
size
,
double
quote
,
double
x
,
double
y
)
{
this
(
size
,
quote
,
x
,
y
);
public
YzgFileVideoImageItemReqVo
(
String
toFile
,
double
size
,
double
quote
,
double
width
,
double
height
)
{
this
(
size
,
quote
,
width
,
height
);
this
.
toFile
=
toFile
;
}
...
...
@@ -84,19 +84,19 @@ public class YzgFileVideoImageItemReqVo extends BaseVo {
this
.
quote
=
quote
;
}
public
double
get
X
()
{
return
x
;
public
double
get
Width
()
{
return
width
;
}
public
void
set
X
(
double
x
)
{
this
.
x
=
x
;
public
void
set
Width
(
double
width
)
{
this
.
width
=
width
;
}
public
double
get
Y
()
{
return
y
;
public
double
get
Height
()
{
return
height
;
}
public
void
set
Y
(
double
y
)
{
this
.
y
=
y
;
public
void
set
Height
(
double
height
)
{
this
.
height
=
height
;
}
}
yzg-util-file/src/main/java/com/yanzuoguang/cloud/file/YzgFileServiceImpl.java
View file @
9cdff7e5
...
...
@@ -6,11 +6,16 @@ import com.yanzuoguang.util.exception.CodeException;
import
com.yanzuoguang.util.helper.DateHelper
;
import
com.yanzuoguang.util.helper.FileHelper
;
import
com.yanzuoguang.util.helper.StringHelper
;
import
org.bytedeco.javacv.FFmpegFrameGrabber
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.multipart.MultipartFile
;
import
javax.imageio.ImageIO
;
import
java.awt.image.BufferedImage
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.nio.file.Files
;
import
java.nio.file.Paths
;
import
java.nio.file.StandardCopyOption
;
...
...
@@ -180,7 +185,39 @@ public class YzgFileServiceImpl implements YzgFileService {
*/
@Override
public
YzgFileVideoImageInfoVo
getInfo
(
String
fromUrl
)
{
return
null
;
YzgFileVideoImageInfoVo
info
=
new
YzgFileVideoImageInfoVo
();
fileConfig
.
init
(
info
,
fromUrl
);
String
serverFullPath
=
fileConfig
.
getServerFullPath
(
fromUrl
);
switch
(
info
.
getType
())
{
case
FileHelper
.
FILE_TYPE_AUDIO
:
{
FFmpegFrameGrabber
grabber
=
new
FFmpegFrameGrabber
(
serverFullPath
);
info
.
setBitrate
(
Double
.
valueOf
(
grabber
.
getVideoBitrate
()));
break
;
}
case
FileHelper
.
FILE_TYPE_VIDEO
:
{
FFmpegFrameGrabber
grabber
=
new
FFmpegFrameGrabber
(
serverFullPath
);
info
.
setBitrate
(
Double
.
valueOf
(
grabber
.
getVideoBitrate
()));
info
.
setWidth
(
Double
.
valueOf
(
grabber
.
getImageWidth
()));
info
.
setHeight
(
Double
.
valueOf
(
grabber
.
getImageHeight
()));
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
:
default
:
{
break
;
}
}
return
info
;
}
/**
...
...
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