سؤال

I've many video files. All the types are different (mkv, avi, mp4, flv, etc.). I want to iterate these files and get the duration of the movies.

Currently I use vlcj which is OK, but the code is a little bit confusing me. I have to play the media before I can get the length. Then stop the media. This is weird, isn't it.

Can I do that better somehow? I've heard about xuggler, but the development has stopped. I need an API or 3rdparty component that is still alive. And I don't want to play the media before I play :)

هل كانت مفيدة؟

المحلول

Finally, I've solved the problem with Xuggle. After setup I had to add these lines, and it works fine:

IContainer container = IContainer.make();
    if (container.open(movie, IContainer.Type.READ, null) < 0) {
        throw new RuntimeException("Cannot open '" + movie + "'");
    }

    logger.info("# Duration (ms): " + ((container.getDuration() == Global.NO_PTS) ? "unknown" : "" + container.getDuration() / 100));
    logger.info("# File size (bytes): " + container.getFileSize());
    logger.info("# Bit rate: " + container.getBitRate());

BTW, the setup was awful, but finally... got this code to work.

نصائح أخرى

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top