# Pull sample on demand from appsink

**URL:** <https://discourse.gstreamer.org/t/pull-sample-on-demand-from-appsink/3857>\
**Category:** General Discussion\
**Tags:** rust\
**Created:** [January 2, 2025, 11:13am UTC](https://discourse.gstreamer.org/t/pull-sample-on-demand-from-appsink/3857 "2025-01-02T11:13:43Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![edgarriba](https://discourse.gstreamer.org/user_avatar/discourse.gstreamer.org/edgarriba/32/495_2.png) [@edgarriba](https://discourse.gstreamer.org/u/edgarriba)\
**Post date:** [January 3, 2025, 11:41am UTC](https://discourse.gstreamer.org/t/pull-sample-on-demand-from-appsink/3857/3 "2025-01-03T11:41:58Z")

</div>

Thanks for the answer ! I’ve seen also that there’s a `try_pull_sample()` with a timeout. I believe this is the functionality I need as for the use case I’m targeting to grab frames at a constant rate for robotics applications.

I have the doubt thought, if the user calls `try_pull_sample()` let’s say with the minimum timeout (1ns) every 30Hz and misses the sample, what happens internally ? Does gstreamer drop the sample or just puts into a queue until the next `pull_sample` call ?

Ideally I want that each time the use call the `grab()` method it gets the latest available frame served by the stream and give ownership to the user with zero-copy (if you could comment [here](https://discourse.gstreamer.org/t/zero-copy-video-frames/3856)).

I tried, `bus.set_sync_handler()` and seems to work well. I guess it’s running a job in the background in any case, right ?

For now I got the following solution

```rust
pub fn grab(&self) -> Result<Option<Image<u8, 3>>, StreamCaptureError> {
    self.appsink
        .try_pull_sample(gst::ClockTime::ZERO)
        .map(Self::extract_image_frame)
        .transpose()
}

```

---

_[View the full topic](https://discourse.gstreamer.org/t/pull-sample-on-demand-from-appsink/3857)._
