To access the contents of a Gst.Buffer
in recent versions, you must first map()
the buffer to get a Gst.MapInfo
, which has a data
attribute of type bytes
(str
in Python 2).
(result, mapinfo) = buf.map(Gst.MapFlags.READ)
assert result
try:
# use mapinfo.data here
pass
finally:
buf.unmap(mapinfo)
You can also access the buffer's constituent Gst.Memory
elements with get_memory()
, and map them individually. (AFAICT, calling Buffer.map()
is equivalent to calling .get_all_memory()
and mapping the resulting Memory
.)
Unfortunately, writing to these buffers is not possible since Python represents them with immutable types even when the Gst.MapFlags.WRITE
flag is set. Instead, you'd have to do something like create a new Gst.Memory
with the modified data, and use Gst.Buffer.replace_all_memory()
.