0

I want to get duration of all video files from "New Folder".

I have list of all videos but i don't know how to got to theirs duration.

public static void main(String[] args) throws IOException {
        File file = new File("C:\\y\\ee\\t\\New Folder");
        File[] list = file.listFiles();
        for (int i = 0; i < list.length; i++) {
                System.out.println(list[i].getName() + "Video duration: ");
        }


    }

I want to get sth like this

video1.webm Video duration: 0:34
video2.webm Video duration: 1:43
video3.webm Video duration: 0:54
F.Hand
  • 73
  • 1
  • 2
  • 13

1 Answers1

0

Hi I found 2 methods that can help for your questions.

Please try out.

1) Use xuggle Library . (http://www.xuggle.com/downloads)

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

you can gind the tutorial here. (https://examples.javacodegeeks.com/desktop-java/xuggler/inspect-a-video-file-with-xuggler/)

2) use windows MediaInfo.exe. (http://www.javacreed.com/how-to-retrieve-the-video-properties/)