C
C
crescent2018-03-06 14:44:39
Java
crescent, 2018-03-06 14:44:39

Java: How to find out the duration of a video file?

The path to the file is given.
You need to know its duration.
Without using video players

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexey Cheremisin, 2018-03-06
@crescent

As already suggested in the other thread, use ffmpeg -i and parse its output. There is also a library https://github.com/bramp/ffmpeg-cli-wrapper for the same and https://github.com/kokorin/Jaffre
Alas, the JMF framework as well as all the alternatives (xuggle etc.) ), somehow not very popular with the java community. Usually, all work with bedia is done in other languages, using some services to connect Java with the necessary functionality :-(
I will be pleasantly surprised and will certainly use it if someone tells me a sane and developing alternative for media in Java.

D
DenisKokorin, 2018-03-18
@DenisKokorin

Thanks for mentioning Jaffree. There are 2 utilities in ffmpeg: ffprobe and ffmpeg.
The simplest: ffprobe <file path> - but this method does not always show the duration correctly, because it only scans the titles of media streams.
More accurate and slightly less fast: ffmpeg -i <path to file> -f null -c copy /dev/null (or just Nul on Windows).

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question