gst-python: When using custom BaseTransform, pad_template != NULL error occurred
I am developing a custom element using gst-python.
I inherited BaseTransform as shown below, created a custom element, added it to the pipeline, and linked it, but an error occurred.
- environment :
❯ sw_vers -productName
macOS
❯ sw_vers -productVersion
13.4
❯ brew info gstreamer
==> gstreamer: stable 1.22.3 (bottled), HEAD
❯ brew info gst-python
==> gst-python: stable 1.20.5 (bottled)
- Source code:
class MyTransform(GstBase.BaseTransform):
__gstmetadata__ = ('CustomTransform', 'Transform', \
'A custom transform element', 'Author Name')
__gsttemplates__ = (Gst.PadTemplate.new("src",
Gst.PadDirection.SRC,
Gst.PadPresence.ALWAYS,
Gst.Caps.from_string("video/x-raw,format=(string)RGB")),
Gst.PadTemplate.new("sink",
Gst.PadDirection.SINK,
Gst.PadPresence.ALWAYS,
Gst.Caps.from_string("video/x-raw,format=(string)RGB")))
def do_transform_ip(self, buf):
# Do something with the buffer in-place
# For simplicity, we just print the buffer size and return
print("Buffer size: ", buf.get_size())
return Gst.FlowReturn.OK
GObject.type_register(MyTransform)
def main():
# Build the pipeline
src = Gst.ElementFactory.make("videotestsrc", "src")
sink = Gst.ElementFactory.make("autovideosink", "sink")
my_transform = MyTransform()
# Create a pipeline
pipeline = Gst.Pipeline.new("mypipeline")
# Add elements into the pipeline
pipeline.add(src)
pipeline.add(my_transform)
pipeline.add(sink)
# Link elements
src.link(my_transform)
my_transform.link(sink)
# Start playing
pipeline.set_state(Gst.State.PLAYING)
# Wait until error or EOS
bus = pipeline.get_bus()
msg = bus.timed_pop_filtered(Gst.CLOCK_TIME_NONE, Gst.MessageType.ERROR | Gst.MessageType.EOS)
# Free resources
pipeline.set_state(Gst.State.NULL)
- Error message:
(<unknown>:56320): GStreamer-Base-CRITICAL **: 15:03:39.106: gst_base_transform_init: assertion 'pad_template != NULL' failed
Edited by 황현동