Plugin is never called but data flows through it
Matteo Foglio
foglio.matteo at gmail.com
Tue Mar 8 16:49:59 UTC 2022
Hello everyone,
My goal is produce some code that can drop video frames when the downstream
pipeline gets too slow to consume them all.
So far, I am fighting with having a dump plugin running.
How is it possible that the following Python Gstreamer plugin is correctly
initiated (it prints `PLUGIN Initialized GstDropFrames` as expected), and
that data flows through it (see attached pipeline) without printing
anything besides the print in the `__init__` function?
```
import logging
import timeit
import math
import traceback
import time
import cv2
import gi
gi.require_version('Gst', '1.0')
gi.require_version('GstBase', '1.0')
gi.require_version('GstVideo', '1.0')
from gi.repository import Gst, GObject, GLib, GstBase, GstVideo #
noqa:F401,F402
from gstreamer.utils import gst_buffer_with_caps_to_ndarray
Gst.init(None)
logger = logging.getLogger(__name__)
class GstDropFrames(GstBase.BaseTransform):
GST_PLUGIN_NAME = 'gstdropframes'
__gstmetadata__ = (
"GstDropFrames",
"Transform",
"Drop frames when the pipeline can't consume them all",
"author"
)
__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(),
)
)
__gproperties__ = {}
def __init__(self):
super(GstDropFrames, self).__init__()
print("PLUGIN Initialized GstDropFrames")
def do_prepare_output_buffer(self, inbuf):
print("PLUGIN do_prepare_output_buffer")
buf = Gst.Buffer.new()
buf.copy_into(inbuf, Gst.BufferCopyFlags.FLAGS |
Gst.BufferCopyFlags.TIMESTAMPS |
Gst.BufferCopyFlags.META | Gst.BufferCopyFlags.MEMORY, 0,
inbuf.get_size())
buf.pts = inbuf.pts
return (Gst.FlowReturn.OK, buf)
def do_transform(self, inbuf, outbuf):
print("PLUGIN do_transform")
# outbuf.copy_into(inbuf, Gst.BufferCopyFlags.FLAGS |
Gst.BufferCopyFlags.TIMESTAMPS |
# Gst.BufferCopyFlags.META | Gst.BufferCopyFlags.MEMORY, 0,
inbuf.get_size())
return Gst.FlowReturn.OK
def do_transform_ip(self, buffer: Gst.Buffer) -> Gst.FlowReturn:
print("PLUGIN do_transform_ip")
return Gst.FlowReturn.OK
# Register plugin to use it from command line
GObject.type_register(GstDropFrames)
__gstelementfactory__ = (
GstDropFrames.GST_PLUGIN_NAME,
Gst.Rank.NONE,
GstDropFrames
)
```
Pipeline:
https://drive.google.com/file/d/1Vu8DR1Puam14k-fUKVBW2bG1gN4AgSPm/view?usp=sharing
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/gstreamer-devel/attachments/20220308/eec4f6f8/attachment.htm>
More information about the gstreamer-devel
mailing list