使用libvlc,如何让libvlc_media_player_get_time()返回更准确的结果?使用60fps视频时,它返回的值最多只能每秒更新几次。有没有办法让帧精确计时?
答案 0 :(得分:7)
这issue表示没有办法从libvlc获得更准确的结果。
但你可以插入它:
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
}