您的位置:首页 > 编程语言 > Java开发

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());                }            }        }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: