java使用Xuggler获得视频时长,分辨率,高宽,码率等信息
2018-03-27 09:47
946 查看
https://download.csdn.net/download/iewdyue/9604651
.获取ts流的时长、大小以及分辨率(用到了Xuggle,需要下载对应jar包)import com.xuggle.xuggler.ICodec;import com.xuggle.xuggler.IContainer;import com.xuggle.xuggler.IStream;import com.xuggle.xuggler.IStreamCoder;
*/ public static void getVedioInfo(String filename){ // first we create a Xuggler container object IContainer container = IContainer.make();
// we attempt to open up the container int result = container.open(filename, IContainer.Type.READ, null);
// check if the operation was successful if (result<0) return ; // query how many streams the call to open found int numStreams = container.getNumStreams(); // query for the total duration long duration = container.getDuration(); // query for the file size long fileSize = container.getFileSize(); long secondDuration = duration/1000000; System.out.println("时长:"+secondDuration+"秒"); System.out.println("文件大小:"+fileSize+"M"); for (int i=0; i IStream stream = container.getStream(i); IStreamCoder coder = stream.getStreamCoder(); if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) { System.out.println("视频宽度:"+coder.getWidth()); System.out.println("视频高度:"+coder.getHeight()); } } }
.获取ts流的时长、大小以及分辨率(用到了Xuggle,需要下载对应jar包)import com.xuggle.xuggler.ICodec;import com.xuggle.xuggler.IContainer;import com.xuggle.xuggler.IStream;import com.xuggle.xuggler.IStreamCoder;
*/ public static void getVedioInfo(String filename){ // first we create a Xuggler container object IContainer container = IContainer.make();
// we attempt to open up the container int result = container.open(filename, IContainer.Type.READ, null);
// check if the operation was successful if (result<0) return ; // query how many streams the call to open found int numStreams = container.getNumStreams(); // query for the total duration long duration = container.getDuration(); // query for the file size long fileSize = container.getFileSize(); long secondDuration = duration/1000000; System.out.println("时长:"+secondDuration+"秒"); System.out.println("文件大小:"+fileSize+"M"); for (int i=0; i IStream stream = container.getStream(i); IStreamCoder coder = stream.getStreamCoder(); if (coder.getCodecType() == ICodec.Type.CODEC_TYPE_VIDEO) { System.out.println("视频宽度:"+coder.getWidth()); System.out.println("视频高度:"+coder.getHeight()); } } }
相关文章推荐
- PHP使用FFmpeg获取视频播放总时长与码率等信息
- JAVA获得总的物理内存、剩余的物理内存、已使用的物理内存等信息
- Android(java)学习笔记250:ContentProvider使用之获得系统联系人信息02(掌握)
- PHP使用FFmpeg获取视频播放总时长与码率等信息
- java获得U盘根目录、读取图片视频头文件信息、获取视频时长
- Android(java)学习笔记249:ContentProvider使用之获得系统联系人信息01
- 如何配置sigar在Linux和Windows下使用java语言获得各种系统信息
- java获得U盘根目录、读取图片视频头文件信息、获取视频时长
- Java网络编程从入门到精通(11):使用NetworkInterface类获得网络接口信息
- 使用Java程序来获得某个集群的NameNode或DataNode的相关信息
- java通过使用ffmpeg获取视频的码率
- 使用Java开发和信息安全相关的程序(CA)
- 使用C#获得系统信息
- 使用WINPCAP获得已安装网卡的详细信息
- 如何计算 一个音视频文件 (.ts)文件 (包含pcr信息). 播放所使用的带宽
- 使用Java RTP传输声音和视频的程序(绝对经典)
- 使用Java访问LDAP服务器中的数据信息
- 在C++中使用cpuid指令获得CPU信息
- 使用ASP获得服务器网卡的MAC地址信息
- 在Java中获得文件的描述信息