xushengqiang 5 роки тому
батько
коміт
55478915d9

+ 10 - 0
pom.xml

@@ -134,6 +134,16 @@
 			<artifactId>poi</artifactId>
 			<version>3.13</version>
 		</dependency>
+		<dependency>
+			<groupId>ws.schild</groupId>
+			<artifactId>jave-core</artifactId>
+			<version>2.4.4</version>
+		</dependency>
+		<dependency>
+			<groupId>ws.schild</groupId>
+			<artifactId>jave-native-win64</artifactId>
+			<version>2.4.4</version>
+		</dependency>
 	</dependencies>
 
 	<dependencyManagement>

+ 111 - 9
src/main/java/cn/efunbox/audio/utils/Test.java

@@ -1,18 +1,37 @@
 package cn.efunbox.audio.utils;
 
-import javazoom.jl.decoder.Bitstream;
 import javazoom.jl.decoder.BitstreamException;
-import javazoom.jl.decoder.Header;
+import lombok.extern.slf4j.Slf4j;
+import ws.schild.jave.MultimediaInfo;
+import ws.schild.jave.MultimediaObject;
 
-import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
 import java.io.IOException;
-import java.net.URL;
-import java.net.URLConnection;
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.nio.channels.FileChannel;
 
+@Slf4j
 public class Test {
     public static void main(String[] args) throws IOException, BitstreamException {
-		URL urlfile = new URL("http://sc1.111ttt.com/2015/1/06/06/99060941326.mp3");
-		URLConnection con = null;
+
+
+//        getFileList("H:\\7m");
+
+        File source = new File("http://baidu-yuwen-video.ai160.com/vs2m/001/00103052/00103052001/00103052001.m3u8");
+
+        String strFileName = source.getName();
+        String readVideoTime = ReadVideoTime(source);
+        String s = ReadVideoSize(source);
+
+        log.info("title : {} ,time : {},size : {}",strFileName,readVideoTime,s);
+
+
+
+/*		URL urlfile = new URL("http://ai-admin-audio.ai160.com/audio/001/00103035/00103035019.mp3");
+        URLConnection con = null;
 		try {
 			con = urlfile.openConnection();
 		} catch (IOException e) {
@@ -22,9 +41,92 @@ public class Test {
 		int b = con.getContentLength();//
 		BufferedInputStream bis = new BufferedInputStream(con.getInputStream());
 		Bitstream bt = new Bitstream(bis);
+
 		Header h = bt.readFrame();
+		int bitrate = h.calculate_framesize();
+		System.out.println(bitrate);
 		int time = (int) h.total_ms(b);
-		System.out.println(time / 1000);
-	}
+		System.out.println(time / 1000);*/
+    }
+
+
+    public static void getFileList(String strPath) {
+        File dir = new File(strPath);
+        File[] files = dir.listFiles(); // 该文件目录下文件全部放入数组
+        if (files != null) {
+            for (int i = 0; i < files.length; i++) {
+                String fileName = files[i].getName();
+                if (files[i].isDirectory()) { // 判断是文件还是文件夹
+                    getFileList(files[i].getAbsolutePath()); // 获取文件绝对路径
+                } else if (fileName.endsWith("ts")) { // 判断文件名是否以.avi结尾
+
+                    File file = files[i];
+
+                    String strFileName = files[i].getName();
+                    String readVideoTime = ReadVideoTime(file);
+                    String s = ReadVideoSize(file);
+
+                    log.info("title : {} ,time : {},size : {}",strFileName,readVideoTime,s);
+
+                } else {
+                    continue;
+                }
+            }
+
+        }
+    }
+
+
+    /**
+     * @return
+     * @描述:获取视频时长
+     * @时间:2018年8月28日 上午10:18:59
+     */
+    static String ReadVideoTime(File source) {
+        String length = "";
+        try {
+            MultimediaObject instance = new MultimediaObject(source);
+            MultimediaInfo result = instance.getInfo();
+            long ls = result.getDuration() / 1000;
+            int hour = (int) (ls / 3600);
+            int minute = (int) (ls % 3600) / 60;
+            int second = (int) (ls - hour * 3600 - minute * 60);
+            length = hour + "'" + minute + "''" + second + "'''";
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
+        return length;
+    }
+
 
+    /**
+     * @param source
+     * @return
+     * @描述:获取视频大小
+     * @时间:2018年8月28日 上午10:30:17
+     */
+    @SuppressWarnings({"resource"})
+    static String ReadVideoSize(File source) {
+        FileChannel fc = null;
+        String size = "";
+        try {
+            FileInputStream fis = new FileInputStream(source);
+            fc = fis.getChannel();
+            BigDecimal fileSize = new BigDecimal(fc.size());
+            size = fileSize.divide(new BigDecimal(1048576), 2, RoundingMode.HALF_UP) + "MB";
+        } catch (FileNotFoundException e) {
+            e.printStackTrace();
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            if (null != fc) {
+                try {
+                    fc.close();
+                } catch (IOException e) {
+                    e.printStackTrace();
+                }
+            }
+        }
+        return size;
+    }
 }

+ 1 - 1
src/main/resources/application-dev.properties

@@ -20,7 +20,7 @@ iaas.user.audio.platform=4
 iaas.user.audio.os=0
 iaas.user.audio.appVer=1.0.0
 iaas.user.audio.terminal=audio
-iaas.user.audio.entryType=1
+iaas.user.audio.entryType=2
 
 
 ########################################################

+ 1 - 1
src/main/resources/application-prd.properties

@@ -20,7 +20,7 @@ iaas.user.audio.platform=4
 iaas.user.audio.os=0
 iaas.user.audio.appVer=1.0.0
 iaas.user.audio.terminal=audio
-iaas.user.audio.entryType=1
+iaas.user.audio.entryType=2
 
 
 ########################################################