INNER CODE UNIT · Java

getVideoDuration

microshow/RxFFmpeg · rxffmpeg/src/main/java/io/microshow/rxffmpeg/AudioVideoUtils.java:153

    public static int getVideoDuration(String videoPath) {
        MediaMetadataRetriever retr = new MediaMetadataRetriever();
        retr.setDataSource(videoPath);
        String rotation = retr.extractMetadata(MediaMetadataRetriever.METADATA_KEY_DURATION); // 视频时长 毫秒
        retr.release();
        return Integer.parseInt(rotation) / 1000;//转为秒
    }

    /**
     * 判断是否是横屏的视频
     *
     * @param videoPath
     * @return
     */
    public static boolean isHorizontalVideo(String videoPath) {
        if (getVideoWidth(videoPath) >= getVideoHeight(videoPath)) {
            return true;
        } else {

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…