How to get video length in java

I used xuggler to get the length of the video, but it gives the wrong length, maybe it is time to read the data from the video using xuggler. But I need to get the actual length or duration of the video.

+4
source share
1 answer

You can get it using getDuration()and methods getFileSize() IContainer. You can do it as follows:

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 the full example here.

Hope this helps

+12
source

All Articles