派生自 projectDept/qhighschool

Administrator
2022-12-06 92027c9960c8e4e8d84db11c2c422254a5b7d38c
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、mov格式)
     * @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
     */