Skip to content

Instantly share code, notes, and snippets.

@fortizc
Last active April 27, 2023 19:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fortizc/d67109eaa021f5ae9a7b72179f67a95b to your computer and use it in GitHub Desktop.
Save fortizc/d67109eaa021f5ae9a7b72179f67a95b to your computer and use it in GitHub Desktop.
A very simple gst plugin in python
#!/usr/local/bin/python3
# -*- Mode: Python -*-
# vi:si:et:sw=4:sts=4:ts=4
# This is a modified version of https://github.com/GStreamer/gst-python/blob/master/examples/plugins/python/identity.py
import gi
gi.require_version("Gst", "1.0")
gi.require_version('GstBase', '1.0')
from gi.repository import Gst, GObject, GstBase
Gst.init(None)
class print_tst(GstBase.BaseTransform):
__gstmetadata__ = ("Print test",
"Transform",
"Simple plugin to string string",
'Felipe Ortiz')
__gsttemplates__ = (Gst.PadTemplate.new("src",
Gst.PadDirection.SRC,
Gst.PadPresence.ALWAYS,
Gst.Caps.new_any()),
Gst.PadTemplate.new("sink",
Gst.PadDirection.SINK,
Gst.PadPresence.ALWAYS,
Gst.Caps.new_any()))
def __init__(self):
GstBase.BaseTransform.__init__(self)
# The problem: when I switch between do_transform_ip and do_transform
# the following message appears:
# fortiz$ gst-launch-1.0 filesrc location=/path/to/any/text/file ! print_tst ! fakesink
# Setting pipeline to PAUSED ...
# Pipeline is PREROLLING ...
# (gst-launch-1.0:12864): GStreamer-CRITICAL **: gst_mini_object_unref: assertion 'mini_object != NULL' failed
# and the command never ends...
# def do_transform(self, in_buff, out_buff):
# err, map_info = in_buff.map(Gst.MapFlags.READ)
# print(map_info.data)
# return Gst.FlowReturn.OK
def do_transform_ip(self, buff):
err, map_info = buff.map(Gst.MapFlags.READ)
print(map_info.data)
return Gst.FlowReturn.OK
GObject.type_register(print_tst)
__gstelementfactory__ = ("print_tst", Gst.Rank.NONE, print_tst)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment