【OpenCV】【JavaCV】【Xuggler】【Java】获取视频的编解码器

2024-05-19 02:08

本文主要是介绍【OpenCV】【JavaCV】【Xuggler】【Java】获取视频的编解码器,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

        FFmpegFrameGrabber grabber = new FFmpegFrameGrabber(inputStream);grabber.start();System.out.println(JSON.toJSONString(grabber));System.out.println(grabber.getVideoMetadata().get("encoder"));

AVC Coding  即为 H.264

{"aspectRatio":1,"audioBitrate":317375,"audioChannels":2,"audioCodec":86018,"audioFrameRate":46.875,"audioMetadata":{"creation_time":"2021-07-27T03:36:46.000000Z","handler_name":"#Mainconcept MP4 Sound Media Handler","language":"eng"},"audioOptions":{},"audioStream":1,"bitsPerPixel":0,"closeInputStream":true,"deinterlace":false,"delayedTime":0,"format":"mov,mp4,m4a,3gp,3g2,mj2","formatContext":{"null":false},"frameNumber":0,"frameRate":25,"gamma":2.2,"imageHeight":1920,"imageMode":"COLOR","imageScalingFlags":0,"imageWidth":1080,"lengthInAudioFrames":708,"lengthInFrames":378,"lengthInTime":15125333,"lengthInVideoFrames":378,"maxDelay":-1,"metadata":{"creation_time":"2021-07-27T03:36:46.000000Z","major_brand":"mp42","minor_version":"0","compatible_brands":"mp42mp41"},"numBuffers":4,"options":{},"pixelFormat":3,"sampleFormat":1,"sampleMode":"SHORT","sampleRate":48000,"sensorPattern":-1,"timeout":10000,"timestamp":0,"triggerMode":false,"videoBitrate":10681406,"videoCodec":27,"videoFrameRate":25,"videoMetadata":{"creation_time":"2021-07-27T03:36:46.000000Z","handler_name":"\u001FMainconcept Video Media Handler","language":"eng","encoder":"AVC Coding"},"videoOptions":{},"videoStream":0
}

Xuggler

手动安装到本地Maven仓库

mvn install:install-file -Dfile=F:\xuggle-xuggler-5.4.jar -DgroupId=xuggle  -DartifactId=xuggle-xuggler  -Dversion=5.4 -Dpackaging=jar

        <!-- https://mvnrepository.com/artifact/xuggle/xuggle-xuggler --><dependency><groupId>xuggle</groupId><artifactId>xuggle-xuggler</artifactId><version>5.4</version></dependency>
public static void main(String[] args) {long startTime =System.currentTimeMillis();String filename = "F:\\share\\XXX.mp4";// first we create a Xuggler container objectIContainer container = IContainer.make();// we attempt to open up the containerint result = container.open(filename, IContainer.Type.READ, null);// check if the operation was successfulif (result < 0) {throw new RuntimeException("Failed to open media file");}// query how many streams the call to open foundint numStreams = container.getNumStreams();// query for the total durationlong duration = container.getDuration();// query for the file sizelong fileSize = container.getFileSize();// query for the bit ratelong bitRate = container.getBitRate();System.out.println("Number of streams: " + numStreams);System.out.println("Duration (ms): " + duration);System.out.println("File Size (bytes): " + fileSize);System.out.println("Bit Rate: " + bitRate);// iterate through the streams to print their meta datafor (int i = 0; i < numStreams; i++) {// find the stream objectIStream stream = container.getStream(i);// get the pre-configured decoder that can decode this stream;IStreamCoder coder = stream.getStreamCoder();System.out.println("*** Start of Stream Info ***");System.out.printf("stream %d: ", i);System.out.printf("type: %s; ", coder.getCodecType());System.out.printf("codec: %s; ", coder.getCodecID());System.out.printf("duration: %s; ", stream.getDuration());System.out.printf("start time: %s; ", container.getStartTime());System.out.printf("timebase: %d/%d; ",stream.getTimeBase().getNumerator(),stream.getTimeBase().getDenominator());System.out.printf("coder tb: %d/%d; ",coder.getTimeBase().getNumerator(),coder.getTimeBase().getDenominator());System.out.println();if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_AUDIO) {System.out.printf("sample rate: %d; ", coder.getSampleRate());System.out.printf("channels: %d; ", coder.getChannels());System.out.printf("format: %s", coder.getSampleFormat());} else if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) {System.out.printf("width: %d; ", coder.getWidth());System.out.printf("height: %d; ", coder.getHeight());System.out.printf("format: %s; ", coder.getPixelType());System.out.printf("frame-rate: %5.2f; ", coder.getFrameRate().getDouble());}System.out.println();System.out.println("*** End of Stream Info ***");}}
Number of streams: 2
Duration (ms): 15125333
File Size (bytes): 20776688
Bit Rate: 10989080
*** Start of Stream Info ***
stream 0: type: CODEC_TYPE_VIDEO; codec: CODEC_ID_H264; duration: 377000; start time: 0; timebase: 1/25000; coder tb: 1/50; 
width: 1080; height: 1920; format: YUV420P; frame-rate: 25.00; 
*** End of Stream Info ***
*** Start of Stream Info ***
stream 1: type: CODEC_TYPE_AUDIO; codec: CODEC_ID_AAC; duration: 726016; start time: 0; timebase: 1/48000; coder tb: 1/48000; 
sample rate: 48000; channels: 2; format: FMT_S16
*** End of Stream Info ***

Xuggler-JAR下载地址

https://www.dcm4che.org/maven2/xuggle/xuggle-xuggler/5.4/xuggle-xuggler-5.4.jar

这篇关于【OpenCV】【JavaCV】【Xuggler】【Java】获取视频的编解码器的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/995748

相关文章

JVM 的类初始化机制

前言 当你在 Java 程序中new对象时,有没有考虑过 JVM 是如何把静态的字节码(byte code)转化为运行时对象的呢,这个问题看似简单,但清楚的同学相信也不会太多,这篇文章首先介绍 JVM 类初始化的机制,然后给出几个易出错的实例来分析,帮助大家更好理解这个知识点。 JVM 将字节码转化为运行时对象分为三个阶段,分别是:loading 、Linking、initialization

Spring Security 基于表达式的权限控制

前言 spring security 3.0已经可以使用spring el表达式来控制授权,允许在表达式中使用复杂的布尔逻辑来控制访问的权限。 常见的表达式 Spring Security可用表达式对象的基类是SecurityExpressionRoot。 表达式描述hasRole([role])用户拥有制定的角色时返回true (Spring security默认会带有ROLE_前缀),去

浅析Spring Security认证过程

类图 为了方便理解Spring Security认证流程,特意画了如下的类图,包含相关的核心认证类 概述 核心验证器 AuthenticationManager 该对象提供了认证方法的入口,接收一个Authentiaton对象作为参数; public interface AuthenticationManager {Authentication authenticate(Authenti

Spring Security--Architecture Overview

1 核心组件 这一节主要介绍一些在Spring Security中常见且核心的Java类,它们之间的依赖,构建起了整个框架。想要理解整个架构,最起码得对这些类眼熟。 1.1 SecurityContextHolder SecurityContextHolder用于存储安全上下文(security context)的信息。当前操作的用户是谁,该用户是否已经被认证,他拥有哪些角色权限…这些都被保

Spring Security基于数据库验证流程详解

Spring Security 校验流程图 相关解释说明(认真看哦) AbstractAuthenticationProcessingFilter 抽象类 /*** 调用 #requiresAuthentication(HttpServletRequest, HttpServletResponse) 决定是否需要进行验证操作。* 如果需要验证,则会调用 #attemptAuthentica

Spring Security 从入门到进阶系列教程

Spring Security 入门系列 《保护 Web 应用的安全》 《Spring-Security-入门(一):登录与退出》 《Spring-Security-入门(二):基于数据库验证》 《Spring-Security-入门(三):密码加密》 《Spring-Security-入门(四):自定义-Filter》 《Spring-Security-入门(五):在 Sprin

Java架构师知识体认识

源码分析 常用设计模式 Proxy代理模式Factory工厂模式Singleton单例模式Delegate委派模式Strategy策略模式Prototype原型模式Template模板模式 Spring5 beans 接口实例化代理Bean操作 Context Ioc容器设计原理及高级特性Aop设计原理Factorybean与Beanfactory Transaction 声明式事物

流媒体平台/视频监控/安防视频汇聚EasyCVR播放暂停后视频画面黑屏是什么原因?

视频智能分析/视频监控/安防监控综合管理系统EasyCVR视频汇聚融合平台,是TSINGSEE青犀视频垂直深耕音视频流媒体技术、AI智能技术领域的杰出成果。该平台以其强大的视频处理、汇聚与融合能力,在构建全栈视频监控系统中展现出了独特的优势。视频监控管理系统EasyCVR平台内置了强大的视频解码、转码、压缩等技术,能够处理多种视频流格式,并以多种格式(RTMP、RTSP、HTTP-FLV、WebS

Java进阶13讲__第12讲_1/2

多线程、线程池 1.  线程概念 1.1  什么是线程 1.2  线程的好处 2.   创建线程的三种方式 注意事项 2.1  继承Thread类 2.1.1 认识  2.1.2  编码实现  package cn.hdc.oop10.Thread;import org.slf4j.Logger;import org.slf4j.LoggerFactory

使用opencv优化图片(画面变清晰)

文章目录 需求影响照片清晰度的因素 实现降噪测试代码 锐化空间锐化Unsharp Masking频率域锐化对比测试 对比度增强常用算法对比测试 需求 对图像进行优化,使其看起来更清晰,同时保持尺寸不变,通常涉及到图像处理技术如锐化、降噪、对比度增强等 影响照片清晰度的因素 影响照片清晰度的因素有很多,主要可以从以下几个方面来分析 1. 拍摄设备 相机传感器:相机传