GstVideo.VideoFrame buffer pointer is None
The buffer
field in a GstVideo.VideoFrame
object appears to unconditionally contain None
rather than the expected Gst.Buffer
. This is a duplicate of this issue on the gst-python repo where the devs seem confident that this is a gobject-introspection issue.
import gi
gi.require_version("Gst", "1.0")
gi.require_version("GstVideo", "1.0")
from gi.repository import Gst, GObject, GstVideo, GLib
Gst.init(None)
SRC = Gst.PadTemplate.new("src", Gst.PadDirection.SRC, Gst.PadPresence.ALWAYS, Gst.Caps.new_any())
SNK = Gst.PadTemplate.new("sink", Gst.PadDirection.SINK, Gst.PadPresence.ALWAYS, Gst.Caps.new_any())
class MissingBufferDemo(GstVideo.VideoFilter):
__gstmetadata__ = ("longname", "class", "description", "author")
__gsttemplates__ = (SRC, SNK)
def do_transform_frame(
self,
inframe: GstVideo.VideoFrame,
outframe: GstVideo.VideoFrame,
) -> Gst.FlowReturn:
if inframe.buffer is None and outframe.buffer is None:
Gst.error("both `GstVideo.VideoFrame` buffers missing")
return Gst.FlowReturn.ERROR
return Gst.FlowReturn.OK
GObject.type_register(MissingBufferDemo)
__gstelementfactory__ = ("missing_buffer_demo", Gst.Rank.NONE, MissingBufferDemo)
if __name__ == "__main__":
pipeline = Gst.parse_launch("videotestsrc ! missing_buffer_demo ! fakesink")
pipeline.set_state(Gst.State.PLAYING)
loop = GLib.MainLoop()
loop.run()
To run, locate this script in a python/
directory on the $GST_PLUGIN_PATH
and run it with a python3 interpreter.
Results:
$ GST_DEBUG=2 python3 missing_buffer_demo.py
0:00:00.402949758 26 0x558cc8a788a0 ERROR python missing_buffer_demo.py:21:do_transform_frame: both `GstVideo.VideoFrame` buffers missing
0:00:00.404208248 26 0x558cc8a788a0 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop:<videotestsrc0> error: Internal data stream error.
0:00:00.405103279 26 0x558cc8a788a0 WARN basesrc gstbasesrc.c:3055:gst_base_src_loop:<videotestsrc0> error: streaming stopped, reason error (-5)
Environment:
$ python3 --version
Python 3.7.6
$ python3 -m pip --freeze
pycairo==1.19.1
PyGObject==3.34.0
$ gst-launch-1.0 --version
gst-launch-1.0 version 1.14.4
GStreamer 1.14.4
http://packages.qa.debian.org/gstreamer1.0
$ apt list --installed | grep gst
gir1.2-gst-plugins-bad-1.0/stable,now 1.14.4-1+b1 amd64 [installed]
gir1.2-gst-plugins-base-1.0/stable,now 1.14.4-2 amd64 [installed]
gir1.2-gstreamer-1.0/stable,now 1.14.4-1 amd64 [installed]
gstreamer1.0-gl/stable,now 1.14.4-2 amd64 [installed,automatic]
gstreamer1.0-libav/stable,now 1.15.0.1+git20180723+db823502-2 amd64 [installed]
gstreamer1.0-plugins-bad/stable,now 1.14.4-1+b1 amd64 [installed]
gstreamer1.0-plugins-base/stable,now 1.14.4-2 amd64 [installed]
gstreamer1.0-plugins-good/stable,now 1.14.4-1 amd64 [installed]
gstreamer1.0-plugins-ugly/stable,now 1.14.4-1 amd64 [installed]
gstreamer1.0-tools/stable,now 1.14.4-1 amd64 [installed]
gstreamer1.0-x/stable,now 1.14.4-2 amd64 [installed,automatic]
libgstreamer-gl1.0-0/stable,now 1.14.4-2 amd64 [installed,automatic]
libgstreamer-plugins-bad1.0-0/stable,now 1.14.4-1+b1 amd64 [installed,automatic]
libgstreamer-plugins-base1.0-0/stable,now 1.14.4-2 amd64 [installed,automatic]
libgstreamer1.0-0/stable,now 1.14.4-1 amd64 [installed,automatic]
libgstreamer1.0-dev/stable,now 1.14.4-1 amd64 [installed]
With a self-compiled libgstpython.so
checked out on gst-python 1.14.4.