Actual time of “nativeGetTimestamp” in “SurfaceTexture”

余生颓废 提交于 2019-12-11 18:54:30

问题


I'm writing a video processing app and need to know the actual time of each frame.

The app works fine at first when I used elapsedRealtime To compute the time offset:

long timeOffset = java.lang.System.currentTimeMillis() - android.os.SystemClock.elapsedRealtime();
long actualTime = timestamp + timeOffset;

But when I used another device, I found some device will use uptimeMillis for the SurfaceTexture.timestamp, so the code sould be:

long timeOffset = java.lang.System.currentTimeMillis() - android.os.SystemClock.uptimeMillis();
long actualTime = timestamp + timeOffset;

So my question is, is there any way to know which time source are the device use for SurfaceTexture?

Although I may compute the closest time source at start of app, but I think it may cause another accident that I can't know yet.

Is there any way to know that?


回答1:


MediaCodec doesn't invent the timestamps. The buffers that MediaCodec return only contain the same values for presentationTimeUs as you pass in the presentationTimeUs parameter to queueInputBuffer, or when using Surface input, is set on the input surface using eglPresentationTimeANDROID.

So you need to check with whichever piece of code that actually produces the timestamps to know what time reference they use.



来源:https://stackoverflow.com/questions/52511236/actual-time-of-nativegettimestamp-in-surfacetexture

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!