With libvlc, how do I get libvlc_media_player_get_time() to return a more accurate result? With 60fps video the value it returns is only updated a few times per second at most. Is there any way to get frame accurate timing?
This issue says that there is no way to get more accurate result from libvlc.
But you can interpolate it:
private long lastPlayTime = 0;
private long lastPlayTimeGlobal = 0;
/**
* Get current play time (interpolated)
* @see https://github.com/caprica/vlcj/issues/74
* @return
*/
public float getCurrentTime(){
long currentTime = directMediaPlayer.getTime();
if (lastPlayTime == currentTime && lastPlayTime != 0){
currentTime += System.currentTimeMillis() - lastPlayTimeGlobal;
} else {
lastPlayTime = currentTime;
lastPlayTimeGlobal = System.currentTimeMillis();
}
return currentTime * 0.001f; //to float
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With