python plugin Buffer.map() not working
Josh Doe
josh at joshdoe.com
Wed Oct 5 13:51:08 UTC 2022
On Mon, Oct 3, 2022 at 5:39 AM Dejan Cotra via gstreamer-devel <
gstreamer-devel at lists.freedesktop.org> wrote:
> [snip] Im writing python plugin, or better yet trying to write python
> plugin 🙂
> [snip] Im writing Trasform plugin (inherits from GstBase.BaseTransform)
> and in do_transform_ip function Im trying to map buffer for reading and
> writing with:
> *succ, info = buf.map(Gst.MapFlags.READ | Gst.MapFlags.WRITE)*
>
> but when I try to write to info.data I get following exception:
> *TypeError: 'bytes' object does not support item assignment*
>
> Any idea how can I fix this? Is there some workaround for this?
>
Can you share a fuller snippet of code? This works for me:
buf = Gst.Buffer.new_allocate(None, 10, None)
succ,info = buf.map(Gst.MapFlags.READ | Gst.MapFlags.WRITE)
bytes(info.data) # uninitialized data, in this case happens to
be b'\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'
info.data[:] = b'0123456789' # write data to buffer
bytes(info.data) # b'0123456789'
# cleanup...
-Josh
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20221005/1e4f3473/attachment.htm>
More information about the gstreamer-devel
mailing list