Reputation: 3752
Is there a way to get the frames per second from vlcj without starting the video playing or displaying the video itself?
Upvotes: 2
Views: 619
Reputation: 31
// Create a VLCJ component and a window (if having a GUI is acceptable for you)
EmbeddedMediaPlayerComponent mediaPlayerComponent = new EmbeddedMediaPlayerComponent();
JFrame frame = new JFrame();
frame.setContentPane(mediaPlayerComponent);
// Make sure the video is not visible nor audible
mediaPlayerComponent.mediaPlayer().audio().setMute(true);
mediaPlayerComponent.mediaPlayer().audio().setVolume(0);
mediaPlayerComponent.setVisible(false);
// Load the file. startXXX() functions are blocking calls, rather than playXXX(), until the video is ready.
frame.setVisible(true);
mediaPlayerComponent.mediaPlayer().media().startPaused("C:\\video.mp4");
// if there are several video tracks, make sure to take the index of the track with the same "id" value.
int index = 0;
for (int i = 0; i < mediaPlayerComponent.mediaPlayer().media().info().videoTracks().size(); ++i) {
if (mediaPlayerComponent.mediaPlayer().media().info().videoTracks().get(i).id() == mediaPlayerComponent.mediaPlayer().video().track()) {
index = i;
break;
}
}
// Get the frame rate (images per second)
double imgRate = (double)mediaPlayerComponent.mediaPlayer().media().info().videoTracks().get(index).frameRate() / mediaPlayerComponent.mediaPlayer().media().info().videoTracks().get(index).frameRateBase();
Upvotes: 1
Reputation: 4146
No, I'm afraid there is no way to do that.
This is not a limitation of vlcj, vlcj provides whatever LibVLC provides.
For applications where I need that sort of information, I resort to running something like the "MediaInfo" tool as a separate process (using commons-exec) and parsing the output.
https://mediaarea.net/en/MediaInfo
Upvotes: 2