Commit fb4341f5 authored by liqin's avatar liqin 💬

bug fixed

parent ea3776a4
......@@ -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>
......
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;
}
}
......@@ -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) {
......
......@@ -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 IOException {
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(), "没有文件可供上传");
}
......
......@@ -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<>();
queryWrapper.select("max(sortorder) as sortorder");
learningContentBoardQueryWrapper.select("max(sortorder) as sortorder");
LearningContentBoard one = this.learningContentBoardService.getOne(learningContentBoardQueryWrapper);
if (one != null && one.getSortorder() != null) {
learningContentBoard.setSortorder(one.getSortorder() + 1);
learningContent.setSortorder(one.getSortorder() + 1);
} else {
learningContentBoard.setSortorder(1);
learningContent.setSortorder(1);
}
this.learningContentBoardService.save(learningContentBoard);
}
......
......@@ -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);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment