使用 libvlc,如何让 libvlc_media_player_get_time() 返回更准确的结果?对于 60fps 视频,它返回的值每秒最多只更新几次。有没有办法获得帧准确的时间?
问问题
3055 次
1 回答
10
这个问题说没有办法从 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
}
于 2013-12-07T07:15:26.743 回答