# Copy on content of input buffer to output buffer

**URL:** <https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902>\
**Category:** DeepStream SDK\
**Created:** [August 30, 2019, 10:08am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902 "2019-08-30T10:08:05Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![sdbims](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sdbims](https://forums.developer.nvidia.com/u/sdbims)\
**Post date:** [August 30, 2019, 10:08am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/1 "2019-08-30T10:08:05Z")

</div>

Hi, can you please provide an example how to copy the content of one gst\_buffer to another gst\_buffer?

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [September 2, 2019, 3:15am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/2 "2019-09-02T03:15:24Z")

</div>

Hi,  
Your request is not very clear, but for customization, we have implemented dsexample:  
[https://docs.nvidia.com/metropolis/deepstream/4.0/dev-guide/index.html#page/DeepStream\_Development\_Guide%2Fdeepstream\_custom\_plugin.html%23](https://docs.nvidia.com/metropolis/deepstream/4.0/dev-guide/index.html#page/DeepStream_Development_Guide%2Fdeepstream_custom_plugin.html%23)

You may refer to README to enable it and try.

```auto
deepstream_sdk_v4.0_jetson\sources\gst-plugins\gst-dsexample\README

```

---

<div class="post-metadata">

**Author:** ![sdbims](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sdbims](https://forums.developer.nvidia.com/u/sdbims)\
**Post date:** [September 2, 2019, 11:28am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/3 "2019-09-02T11:28:29Z")

</div>

Hi DaneLLL, thank you for you reply.  
I’m trying to implement a function similar to gst\_dsexample\_transform\_ip but since my transformation is not “in place” I want to use something like gst\_dsexample\_transform with an output buffer. Can you provide an example on how to properly set up this buffer and as a first operation, fill the output buffer with valid data (for example the frame-data which is stored in the input buffer)?

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [September 3, 2019, 4:00am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/4 "2019-09-03T04:00:28Z")

</div>

Hi,  
Please refer to [https://developer.gnome.org/gstreamer-libs/stable/GstBaseTransform.html](https://developer.gnome.org/gstreamer-libs/stable/GstBaseTransform.html)

```auto
/* transform */
GstFlowReturn (*transform) (GstBaseTransform *trans, GstBuffer *inbuf,
                             GstBuffer *outbuf);
GstFlowReturn (*transform_ip) (GstBaseTransform *trans, GstBuffer *buf);

```

In the sample code it registers a transform\_ip callback. You can do processing on the inbuf and it will be copied to outbuf.

Above suggestion should work fine for your usecase, but for more flexibility, you may try to register a transform callback and do full implementation.

---

<div class="post-metadata">

**Author:** ![sdbims](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sdbims](https://forums.developer.nvidia.com/u/sdbims)\
**Post date:** [September 3, 2019, 8:00am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/5 "2019-09-03T08:00:51Z")

</div>

> [@DaneLLL](#):
>
> Above suggestion should work fine for your usecase, but for more flexibility, you may try to register a transform callback and do full implementation.

Hi DaneLLL, thank you for the answer, I am currently trying to implement a function which is based on gst\_dsexample\_transform\_ip. The example provides only code to read the GstBuffer. Can you provide an example on how to write data to this buffer?

Even a minimal working example like this doesn’t work:

```auto
gint size = 10;
inbuf = gst_buffer_new_allocate(NULL, size, NULL);
gst_buffer_fill(inbuf, 0, &size, sizeof(size));

```

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [September 3, 2019, 8:15am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/6 "2019-09-03T08:15:17Z")

</div>

Hi,  
With further investigation, it may not be possible to implement transform callback based on NvBufSurface. Certain hookup between NvBufSurface and GstBuffer are private.

We suggest you do processing in transform\_ip. The inbuf will be copied to outbuf after the callback.

---

<div class="post-metadata">

**Author:** ![sdbims](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@sdbims](https://forums.developer.nvidia.com/u/sdbims)\
**Post date:** [September 3, 2019, 11:14am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/7 "2019-09-03T11:14:04Z")

</div>

Hi DaneLLL,  
thank you for the hint, I implemented the function transform\_ip and did a NvBufSurfaceCopy to copy the surface from one location to another, therefore I can process the data and write back to the original inbuf.

---

<div class="post-metadata">

**Author:** ![DaneLLL](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/danelll/32/14043_2.png) [@DaneLLL](https://forums.developer.nvidia.com/u/DaneLLL)\
**Post date:** [September 4, 2019, 1:26am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/8 "2019-09-04T01:26:13Z")

</div>

Hi,  
Great to hear that and thanks for sharing the solution. It can help other users who is working on similar usecases.

---

<div class="post-metadata">

**Author:** ![ChrisDing](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/chrisding/32/14043_2.png) [@ChrisDing](https://forums.developer.nvidia.com/u/ChrisDing)\
**Post date:** [September 5, 2019, 5:16am UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/9 "2019-09-05T05:16:41Z")

</div>

transform plugin example:  
[url][DeepStream SDK FAQ - DeepStream SDK - NVIDIA Developer Forums](https://devtalk.nvidia.com/default/topic/1061492/deepstream-sdk/deepstream-sdk-4-0-faq/%5B/url%5D) → 4. Here is gstnvsegvisual.cpp code

---

<div class="post-metadata">

**Author:** ![TomNVIDIA](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/tomnvidia/32/14181_2.png) [@TomNVIDIA](https://forums.developer.nvidia.com/u/TomNVIDIA)\
**Post date:** [October 12, 2021, 4:19pm UTC](https://forums.developer.nvidia.com/t/copy-on-content-of-input-buffer-to-output-buffer/80902/10 "2021-10-12T16:19:15Z")

</div>


