Java - How can I find out what codec a video is using

25 views Asked by At

I am using in my JavaFX application a MediaView with the javafx.scene.media classes Media and MediaPlayer. The content are rather short mp4 movies, that are typically only ~3 secs long. I use a test loop, where I try to repeat one of these movies 45 times - this number reflects my minimum number of repeats, when really using the application.

While still on OpenJFX 17 I had a hard time, since I got in about 10% of the attempts MediaExceptions - we are talking about the same file - and more important, stalled or even no display for some of the 45 repetitions. I played around with different versions of the movie with different frames per second settings, and different bit rates. No setup worked reliable, and differences in stability where not significant.

Anyway, since I moved recently to OpenJFX 19, I tried what happens, if I convert my movie to the H265 codec. And at least the first three test runs worked without any problem. Therefore, in real life, I want to test whether a movie is H265 coded and inform the user to consider re-coding, if not. How can I check the movie codec using java?

Thank you in advance.

0

There are 0 answers