java使用Xuggler获得视频时长,分辨率,高宽,码率等信息

本文介绍了一种使用Xuggle库来获取TS流文件的关键信息的方法,包括视频的时长、大小及分辨率等。通过Java代码实现了对指定文件的读取,并展示了如何解析这些基本信息。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >


https://download.youkuaiyun.com/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());
                }
            }
    
    }


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值