javascript api - time difference
PlannedNx server and Desktop Client verision: 5.1.4.38659
Hello,
I'm using javascript api to set the required time in the desktop client from our webpage. After that, the timestamp I'm seeing on the nx-timeline and on the camera tile is always a couple of seconds off the one I requested via vms.tab.setItemParams() followed by vms.tab.syncWith(). Here is my update method for reference:
async updateTab() {
if (!this.vms) return
const state: TabState = await this.vms.tab.state()
const camera = state.items.find(item => item.resource.type === 'camera')
if (!camera) return
const itemId = camera.id
const playbackRate = this.isPlaying ? 1 : 0
const itemParams = {
focused: true,
media: {
speed: playbackRate,
timestampMs: this.seekTime.getTime(),
timelineSelection: { startTimeMs: this.periodStart.getTime(), durationMs: this.periodEnd.getTime() - this.periodStart.getTime() },
}
}
const error = await this.vms.tab.setItemParams(itemId, itemParams)
if (error.code != this.vms.ErrorCode.success) {
alert(`Can't set item parameters: ${error.description}`)
}
else
await this.vms.tab.syncWith(itemId)
}
-
Checking this I've also noticed that when dragging the part of the indicator with the time on it, the time differs between the timeline and the camera tile, but when I'm clicking on the timeline itself it is the same.
0 -
Thanks for your question.
If I understanding correctly, you were asking the question with the following operations:1) If you use the desktop client, you select the timeline of a camera, you can see the same timestamp on the camera playback (bottom-corner).
2) If you use the inClient JS API, you specify the timestamp of a camera, but you can't see the same timestamp on the camera playback (bottom-corner).
In this case, if you did not use the calculation, let us say you try to specify the fixed timestamp, will it still have the same behavior? Thanks.
ex:
media: {
speed: playbackRate,
//Just example, try a fixed value
timestampMs: 1725256737,
timelineSelection: { startTimeMs: 1725256737, durationMs: 10 },
}0 -
Hi Ichiro,
1 & 2 yes
I did the test with fixed values (on button click for simplicity & removed tab.syncWith() from my method for the test). The end result is still same, but I've noticed that the indicator on the timeline shows correct timestamp for a brief moment and then jumps a few seconds back (a blue line shows on the timeline where the requested timestamp is).
const itemParams = {
focused: true,
media: {
speed: 0,
timestampMs: 1721746535000,
timelineSelection: { startTimeMs: 1721746535000, durationMs: 10 },
}
}After click:Requested time: 7/23/2024 4:55:35 PMAlso with other fixed timestamp:Requested time: 7/23/2024 4:55:22 PM0 -
Actually not a blue line but a selection. With durationMs: 1000
0 -
Thanks for the test.
The result looks like the time between your camera/server/client might not be synchronised.
- Have you check if the client/server are both synchornized the time to any Internet time server?
- Is your camera using the proper time? I mean the camera system time is correct if you can check again?
There is one more test you can check - You can use the API to download the video with the same timestamp to see if that is the same video showing on the client. Ex:https://<NxServerIp>:7001/media/{cameraId}.webm?pos=1725330609682&accurate_seek=true
Will you see the same video on the desktop client via JSAPI and the stream via API?0
Please sign in to leave a comment.
Comments
5 comments