java使用xuggler读取视频信息

 附:xuggler官网

下面是xuggler提供的demo:

  public static void main(String[] args) {
        String filename = "D:\\project\\advert\\advert\\src\\main\\resources\\123.mp4";
        // 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)
            throw new RuntimeException("Failed to open media file");
        // 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();
        // query for the bit rate
        long 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 data
        for (int i = 0; i < numStreams; i++) {
            // find the stream object
            IStream 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());
            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 ***");

        }
    }

启动报错:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x000000006ee76520, pid=13948, tid=0x0000000000001ff4
#
# JRE version: Java(TM) SE Runtime Environment (8.0_201-b09) (build 1.8.0_201-b09)
# Java VM: Java HotSpot(TM) 64-Bit Server VM (25.201-b09 mixed mode windows-amd64 compressed oops)
# Problematic frame:
# C  [xuggle6627392615720426313.dll+0x736520]
#
# Failed to write core dump. Minidumps are not enabled by default on client versions of Windows
#
# An error report file with more information is saved as:
# D:\project\advert\advert\hs_err_pid13948.log
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.java.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Process finished with exit code 1

先说下我的环境:jdk1.8 64位 ;win10 ;idea2019.2;xuggler 5.4

解决办法:

     将jdk 64位切换成32位;

原先:

切换后:

然后重新运行main方法,发现控制台并无错误提示; 

 

ps:

国外论坛中两篇帖子提供的办法:

Xuggler - 打开mp4文件崩溃/阻止程序

Xuggler - 打开mp4文件崩溃的程序

 

125分50秒---162.81M---LabView01---第10章数据的显示.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView01-第10章数据的显示.wmv 92分2秒---143.46M---LabView02---第11章文件的IO及保存.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView02-第11章文件的IO及保存.wmv 37分22秒---58.09M---LabView03---第12章LabVIEW的通信.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView03-第12章LabVIEW的通信.wmv 9分58秒---21.2M---LabView04---第13章LabVIEW与其它软件的连接.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView04-第13章LabVIEW与其它软件的连接.wmv 4分45秒---9.99M---LabView05---第14章LabVIEW中子VI的设置及调用.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView05-第14章LabVIEW中子VI的设置及调用.wmv 34分30秒---61.03M---LabView06---第15章其它高级技巧.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView06-第15章其它高级技巧.wmv 9分41秒---11.37M---LabView07---第2章第一个LabVIEW例子.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView07-第2章第一个LabVIEW例子.wmv 86分58秒---140.25M---LabView08---第3章基本元素.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView08-第3章基本元素.wmv 76分48秒---143.72M---LabView09---第4章程序结构.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView09-第4章程序结构.wmv 5分46秒---14.67M---LabView10---第5章数据采集.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView10-第5章数据采集.wmv 12分50秒---18.35M---LabView11---第6章数据传输及电脑接口.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView11-第6章数据传输及电脑接口.wmv 59分57秒---87.83M---LabView12---第7章数据的分析及处理.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView12-第7章数据的分析及处理.wmv 42分4秒---61.02M---LabView13---第8章LabVIEW的信号调理.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView13-第8章LabVIEW的信号调理.wmv 132分19秒---178.86M---LabView14---第9章分析处理中数学计算.wmv---F:/Resource/video/硬件/AltiumDesigner/LabView14-第9章分析处理中数学计算.wmv
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值