From 1da190e7f267bcd3501884f3aeaac7476850fec7 Mon Sep 17 00:00:00 2001
From: EricsHu <hrr145632>
Date: 星期日, 26 十一月 2023 17:53:03 +0800
Subject: [PATCH] 优化菜单查询
---
src/main/java/com/qxueyou/scc/sys/utils/VideoUtil.java | 28 ++++++++++++++++++----------
1 files changed, 18 insertions(+), 10 deletions(-)
diff --git a/src/main/java/com/qxueyou/scc/sys/utils/VideoUtil.java b/src/main/java/com/qxueyou/scc/sys/utils/VideoUtil.java
index 2bfd73d..b805f8f 100644
--- a/src/main/java/com/qxueyou/scc/sys/utils/VideoUtil.java
+++ b/src/main/java/com/qxueyou/scc/sys/utils/VideoUtil.java
@@ -2,6 +2,7 @@
import com.coremedia.iso.IsoFile;
+import java.io.File;
import java.io.IOException;
@@ -10,21 +11,28 @@
/**
- * 获取视频文件的播放长度(mp4、mov格式)
+ * 鑾峰彇瑙嗛鏂囦欢鐨勬挱鏀鹃暱搴�(mp4銆乵ov鏍煎紡)
* @param videoPath
- * @return 单位为毫秒
+ * @return 鍗曚綅涓烘绉�
*/
public static long getMp4Duration(String videoPath) throws IOException {
- IsoFile isoFile = new IsoFile(videoPath);
- long lengthInSeconds =
- isoFile.getMovieBox().getMovieHeaderBox().getDuration() /
- isoFile.getMovieBox().getMovieHeaderBox().getTimescale();
- return lengthInSeconds;
+ try {
+ File file = File.createTempFile("temp", ".mp4"); //鍒涘缓涓存椂鏂囦欢
+ Image2Binary.toBDFile(videoPath,file.getCanonicalPath());
+ IsoFile isoFile = new IsoFile(file.getPath());
+ long lengthInSeconds =
+ isoFile.getMovieBox().getMovieHeaderBox().getDuration() /
+ isoFile.getMovieBox().getMovieHeaderBox().getTimescale();
+ return lengthInSeconds;
+ }catch (Exception e){
+ e.printStackTrace();
+ return 0;
+ }
}
/**
- * 得到语音或视频文件时长,单位秒
+ * 寰楀埌璇煶鎴栬棰戞枃浠舵椂闀�,鍗曚綅绉�
* @param filePath
* @return
* @throws IOException
@@ -48,7 +56,7 @@
}
/**
- * 得到语音或视频文件时长,单位秒
+ * 寰楀埌璇煶鎴栬棰戞枃浠舵椂闀�,鍗曚綅绉�
* @param filePath
* @return
* @throws IOException
@@ -72,7 +80,7 @@
/**
- * 得到文件格式
+ * 寰楀埌鏂囦欢鏍煎紡
* @param path
* @return
*/
--
Gitblit v1.8.0