Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i get video length in java

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 or duration.

like image 292
Srikanth Shanigaram Avatar asked May 01 '15 09:05

Srikanth Shanigaram


1 Answers

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

like image 65
MaVRoSCy Avatar answered Nov 07 '22 08:11

MaVRoSCy