How can i get video length in java

前端 未结 1 1833
南方客
南方客 2020-12-20 22:45

I used xuggler to get the video length but it is giving wrong length may be it is time for reading data from video file using xuggler. But i need to get actual video length

相关标签:
1条回答
  • 2020-12-20 23:40

    You can get it with the getDuration() and getFileSize() method of IContainer. You can do it like this:

    private static final String filename = "c:/myvideo.mp4";
    IContainer container = IContainer.make();
    int result = container.open(filename, IContainer.Type.READ, null);
    long duration = container.getDuration();
    long fileSize = container.getFileSize();
    

    You can see a complete example here

    Hope this helps

    0 讨论(0)
提交回复
热议问题