# getSVOPositionAtTimestamp() doesn't work as expected

**URL:** <https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298>\
**Category:** C++\
**Created:** [March 10, 2025, 4:42pm UTC](https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298 "2025-03-10T16:42:29Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![roncapat](https://community.stereolabs.com/user_avatar/community.stereolabs.com/roncapat/32/960_2.png) [@roncapat](https://community.stereolabs.com/u/roncapat)\
**Post date:** [March 10, 2025, 4:42pm UTC](https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298/1 "2025-03-10T16:42:29Z")

</div>

I have an SVO2 file.

First of all, I check initial and final timestamps.

```cpp
auto n = zed.getSVONumberOfFrames();
zed.grab(runParameters);
auto ts0 = zed.getTimestamp(sl::TIME_REFERENCE::IMAGE);
zed.setSVOPosition(n-2);
zed.grab(runParameters);
auto ts1 = zed.getTimestamp(sl::TIME_REFERENCE::IMAGE);
RCLCPP_INFO(get_logger(), "SVO file starts at %f and ends at %f [duration: %f]", slTime2Ros(ts0).seconds(), slTime2Ros(ts1).seconds(), slTime2Ros(ts1).seconds()- slTime2Ros(ts0).seconds());
zed.setSVOPosition(0);

```

I get:

```auto
SVO file starts at 1741616106.944607 and ends at 1741616375.278633 [duration: 268.334026]

```

Then, I do:

```cpp
int ret = zed.getSVOPositionAtTimestamp(1741616118701639000); 

```

so I ask to seek a frame at a timestamp in between initial and final timestamp.

However, the index I get as result is the **last frame** of the SVO, not something that falls in the middle. This is not expected.

How can I solve this problem?

---

<div class="post-metadata">

**Author:** ![roncapat](https://community.stereolabs.com/user_avatar/community.stereolabs.com/roncapat/32/960_2.png) [@roncapat](https://community.stereolabs.com/u/roncapat)\
**Post date:** [March 10, 2025, 5:25pm UTC](https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298/2 "2025-03-10T17:25:03Z")

</div>

Moreover, I would propose the API `getSVOTimestampAtPosition(int pos)` for easy access to timestamps inside the SVO.

---

<div class="post-metadata">

**Author:** ![roncapat](https://community.stereolabs.com/user_avatar/community.stereolabs.com/roncapat/32/960_2.png) [@roncapat](https://community.stereolabs.com/u/roncapat)\
**Post date:** [March 10, 2025, 5:52pm UTC](https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298/3 "2025-03-10T17:52:43Z")

</div>

I did an additional test, looping through some timestamps (15 Hz):

```auto
SVO file starts at 1741616106.944607019 and ends at 1741616375.278632879 [duration: 268.334025860]
SVO position restored to 0
Query: 1741616106.944607019 Index: 0
Query: 1741616107.011273623 Index: 4035
Query: 1741616107.077940226 Index: 4035
Query: 1741616107.144607067 Index: 4035
Query: 1741616107.211273670 Index: 4035
Query: 1741616107.277940273 Index: 4035
Query: 1741616107.344606876 Index: 4035
Query: 1741616107.411273718 Index: 4035
Query: 1741616107.477940321 Index: 4035
Query: 1741616107.544606924 Index: 4035
Query: 1741616107.611273766 Index: 4035
Query: 1741616107.677940130 Index: 4035
Query: 1741616107.744606972 Index: 4035
Query: 1741616107.811273813 Index: 4035
Query: 1741616107.877940178 Index: 4035
Query: 1741616107.944607019 Index: 4035
Query: 1741616108.011273623 Index: 4035
Query: 1741616108.077940226 Index: 4035
Query: 1741616108.144607067 Index: 4035
Query: 1741616108.211273670 Index: 4035
Query: 1741616108.277940273 Index: 4035
...

```

so it seems every timestamp after the first is marked as the last frame by the `getSVOPositionAt Timestamp`

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [March 13, 2025, 7:11pm UTC](https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298/4 "2025-03-13T19:11:33Z")

</div>

Hi @roncapat  
thank you for reporting this problem. Ith as been logged and it will be solved with one of the next SDK releases.

---

<div class="post-metadata">

**Author:** ![roncapat](https://community.stereolabs.com/user_avatar/community.stereolabs.com/roncapat/32/960_2.png) [@roncapat](https://community.stereolabs.com/u/roncapat)\
**Post date:** [May 16, 2025, 5:05pm UTC](https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298/5 "2025-05-16T17:05:36Z")

</div>

Looking at the changelog, has it been fixed in 5.0.1 (RC) ?

---

<div class="post-metadata">

**Author:** ![Myzhar](https://community.stereolabs.com/user_avatar/community.stereolabs.com/myzhar/32/11_2.png) [@Myzhar](https://community.stereolabs.com/u/Myzhar)\
**Post date:** [May 19, 2025, 7:40am UTC](https://community.stereolabs.com/t/getsvopositionattimestamp-doesnt-work-as-expected/8298/6 "2025-05-19T07:40:59Z")

</div>

It’s supposed to has been fixed:

 ![image](https://community.stereolabs.com/uploads/default/original/2X/3/3b263b5c351719b889b65c8071cb287a43c43565.png)
