Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
C
chnmuseum-party
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
liqin
chnmuseum-party
Commits
fb4341f5
Commit
fb4341f5
authored
Apr 02, 2021
by
liqin
💬
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
bug fixed
parent
ea3776a4
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
78 additions
and
4 deletions
+78
-4
pom.xml
pom.xml
+13
-0
FrameGrabberKit.java
...senergy/chnmuseum/party/common/video/FrameGrabberKit.java
+59
-0
ExhibitionBoardController.java
...useum/party/web/controller/ExhibitionBoardController.java
+1
-0
FileUploadController.java
.../chnmuseum/party/web/controller/FileUploadController.java
+1
-1
LearningContentController.java
...useum/party/web/controller/LearningContentController.java
+3
-3
VideoContentController.java
...hnmuseum/party/web/controller/VideoContentController.java
+1
-0
No files found.
pom.xml
View file @
fb4341f5
...
...
@@ -264,6 +264,19 @@
<artifactId>
lombok
</artifactId>
<scope>
provided
</scope>
</dependency>
<!--javacv基础包,包含javacv和javacpp,必须-->
<dependency>
<groupId>
org.bytedeco
</groupId>
<artifactId>
javacv
</artifactId>
<version>
1.5.5
</version>
</dependency>
<!-- ffmpeg,可选 -->
<dependency>
<groupId>
org.bytedeco
</groupId>
<artifactId>
ffmpeg-platform
</artifactId>
<version>
4.3.2-1.5.5
</version>
</dependency>
</dependencies>
<build>
...
...
src/main/java/cn/wisenergy/chnmuseum/party/common/video/FrameGrabberKit.java
0 → 100644
View file @
fb4341f5
package
cn
.
wisenergy
.
chnmuseum
.
party
.
common
.
video
;
import
org.bytedeco.javacv.FFmpegFrameGrabber
;
import
org.bytedeco.javacv.Frame
;
import
org.bytedeco.javacv.Java2DFrameConverter
;
import
javax.imageio.ImageIO
;
import
java.awt.*
;
import
java.awt.image.BufferedImage
;
import
java.io.ByteArrayInputStream
;
import
java.io.ByteArrayOutputStream
;
import
java.io.InputStream
;
/**
* 截取视频图片
*/
public
class
FrameGrabberKit
{
/**
* 获取指定视频的帧并保存为图片至指定目录
*/
public
static
InputStream
fetchFrame
(
String
videoUrl
)
throws
Exception
{
FFmpegFrameGrabber
ff
=
new
FFmpegFrameGrabber
(
videoUrl
);
ff
.
start
();
int
lenght
=
ff
.
getLengthInFrames
();
int
i
=
0
;
int
interceptionFrames
=
30
;
//截取第几帧
//默认截取第50帧,如果第50帧大于视频总帧数的8成直接取长度lenght * 0.3
if
(
interceptionFrames
>=
lenght
*
0.8
)
{
interceptionFrames
=
(
int
)
(
lenght
*
0.3
);
}
Frame
f
=
null
;
while
(
i
<
lenght
)
{
// 过滤 前 interceptionFrames 帧,避免出现全黑的图片,依自己情况而定
f
=
ff
.
grabFrame
();
if
((
i
>
interceptionFrames
)
&&
(
f
.
image
!=
null
))
{
break
;
}
i
++;
}
int
imageWidth
=
f
.
imageWidth
;
int
imageHeight
=
f
.
imageHeight
;
// 对截取的帧进行等比例缩放
// int width = 800;
// int height = (int) (((double) width / owidth) * oheight);
Java2DFrameConverter
converter
=
new
Java2DFrameConverter
();
BufferedImage
fecthedImage
=
converter
.
getBufferedImage
(
f
);
BufferedImage
bi
=
new
BufferedImage
(
imageWidth
,
imageHeight
,
BufferedImage
.
TYPE_3BYTE_BGR
);
bi
.
getGraphics
().
drawImage
(
fecthedImage
.
getScaledInstance
(
imageWidth
,
imageHeight
,
Image
.
SCALE_SMOOTH
),
0
,
0
,
null
);
ByteArrayOutputStream
baos
=
new
ByteArrayOutputStream
();
ImageIO
.
write
(
bi
,
"png"
,
baos
);
InputStream
inputStream
=
new
ByteArrayInputStream
(
baos
.
toByteArray
());
//ff.flush();
ff
.
stop
();
return
inputStream
;
}
}
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/ExhibitionBoardController.java
View file @
fb4341f5
...
...
@@ -207,6 +207,7 @@ public class ExhibitionBoardController extends BaseController {
if
(
boardCopyrightOwnerIdList
!=
null
&&
!
boardCopyrightOwnerIdList
.
isEmpty
())
{
lambdaQueryWrapper
.
in
(
ExhibitionBoard:
:
getBoardCopyrightOwnerId
,
boardCopyrightOwnerIdList
);
}
lambdaQueryWrapper
.
orderByDesc
(
ExhibitionBoard:
:
getCreateTime
);
List
<
ExhibitionBoard
>
exhibitionBoardList
=
exhibitionBoardService
.
list
();
for
(
ExhibitionBoard
exhibitionBoard
:
exhibitionBoardList
)
{
if
(
exhibitionBoard
.
getBoardCopyrightOwnerId
()
!=
null
)
{
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/FileUploadController.java
View file @
fb4341f5
...
...
@@ -343,7 +343,7 @@ public class FileUploadController extends BaseController {
@PostMapping
(
value
=
"/video/content/upload"
,
headers
=
"content-type=multipart/form-data"
,
consumes
=
MediaType
.
MULTIPART_FORM_DATA_VALUE
)
@RequiresPermissions
(
"file:video:content:upload"
)
@ApiOperation
(
value
=
"展板视频上传"
,
notes
=
"展板视频上传"
)
public
Map
<
String
,
Object
>
uploadContentVideo
(
@RequestPart
(
"file"
)
MultipartFile
[]
files
)
throws
IO
Exception
{
public
Map
<
String
,
Object
>
uploadContentVideo
(
@RequestPart
(
"file"
)
MultipartFile
[]
files
)
throws
Exception
{
if
(
files
==
null
||
files
.
length
==
0
)
{
throw
new
InterfaceException
(
RESPONSE_CODE_ENUM
.
SERVER_ERROR
.
getResultCode
(),
"没有文件可供上传"
);
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/LearningContentController.java
View file @
fb4341f5
...
...
@@ -107,12 +107,12 @@ public class LearningContentController extends BaseController {
for
(
String
exhibitionBoardId
:
exhibitionBoardIdList
)
{
LearningContentBoard
learningContentBoard
=
LearningContentBoard
.
builder
().
exhibitionBoardId
(
exhibitionBoardId
).
learningContentId
(
learningContentId
).
build
();
QueryWrapper
<
LearningContentBoard
>
learningContentBoardQueryWrapper
=
new
QueryWrapper
<>();
q
ueryWrapper
.
select
(
"max(sortorder) as sortorder"
);
learningContentBoardQ
ueryWrapper
.
select
(
"max(sortorder) as sortorder"
);
LearningContentBoard
one
=
this
.
learningContentBoardService
.
getOne
(
learningContentBoardQueryWrapper
);
if
(
one
!=
null
&&
one
.
getSortorder
()
!=
null
)
{
learningContent
Board
.
setSortorder
(
one
.
getSortorder
()
+
1
);
learningContent
.
setSortorder
(
one
.
getSortorder
()
+
1
);
}
else
{
learningContent
Board
.
setSortorder
(
1
);
learningContent
.
setSortorder
(
1
);
}
this
.
learningContentBoardService
.
save
(
learningContentBoard
);
}
...
...
src/main/java/cn/wisenergy/chnmuseum/party/web/controller/VideoContentController.java
View file @
fb4341f5
...
...
@@ -175,6 +175,7 @@ public class VideoContentController extends BaseController {
if
(
StringUtils
.
isNotBlank
(
videoContentCopyrightOwnerId
))
{
lambdaQueryWrapper
.
eq
(
VideoContent:
:
getVideoContentCopyrightOwnerId
,
videoContentCopyrightOwnerId
);
}
lambdaQueryWrapper
.
orderByDesc
(
VideoContent:
:
getCreateTime
);
List
<
VideoContent
>
videoContentList
=
videoContentService
.
list
(
lambdaQueryWrapper
);
return
getResult
(
videoContentList
);
}
...
...
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