本文主要是介绍java获取视频文件的编解码器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
java获取视频文件的编解码器
引入jar包:
<dependency><groupId>org.bytedeco</groupId><artifactId>javacv-platform</artifactId><version>1.5.9</version></dependency>
测试类
package com.jd.brand.approve.controller.approve;import org.bytedeco.ffmpeg.global.avcodec;
import org.bytedeco.javacv.FFmpegFrameGrabber;import java.io.File;public class VideoDecoder {//HEVC,AACpublic static void main(String[] args) {String videoPath = "/Users/xuhaojie/Desktop/视频.mp4"; // 视频文件路径try {final FFmpegFrameGrabber fFmpegFrameGrabber = new FFmpegFrameGrabber(videoPath);fFmpegFrameGrabber.start();final int videoCodec = fFmpegFrameGrabber.getVideoCodec();final String videoCodecName = fFmpegFrameGrabber.getVideoCodecName();System.out.println("h264:" + avcodec.AV_CODEC_ID_H264);System.out.println("h265:" + avcodec.AV_CODEC_ID_H265);System.out.println("hevc:" + avcodec.AV_CODEC_ID_HEVC);System.out.println(videoCodec);} catch (Exception e) {e.printStackTrace();}}
}
执行结果
Input #0, mov,mp4,m4a,3gp,3g2,mj2, from '/Users/xuhaojie/Desktop/视频.mp4':Metadata:major_brand : mp42minor_version : 1compatible_brands: isommp41mp42creation_time : 2024-01-11T05:42:21.000000ZDuration: 00:00:15.00, start: 0.000000, bitrate: 5703 kb/sStream #0:0[0x1](zho): Audio: aac (LC) (mp4a / 0x6134706D), 48000 Hz, stereo, fltp, 124 kb/s (default)Metadata:creation_time : 2024-01-11T05:42:21.000000Zhandler_name : Core Media Audiovendor_id : [0][0][0][0]Stream #0:1[0x2](und): Video: hevc (Main 10) (hvc1 / 0x31637668), yuv420p10le(tv, bt709, progressive), 768x1366 [SAR 1:1 DAR 384:683], 5460 kb/s, 25 fps, 25 tbr, 25k tbn (default)Metadata:creation_time : 2024-01-11T05:42:21.000000Zhandler_name : Core Media Videovendor_id : [0][0][0][0]
h264:27
h265:173
hevc:173
173
这篇关于java获取视频文件的编解码器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!