<html><head></head><body><div style="color:#000; background-color:#fff; font-family:lucida console, sans-serif;font-size:13px"><div id="yui_3_16_0_ym19_1_1512653841324_28105"><span id="yui_3_16_0_ym19_1_1512653841324_28123">You might want to subclass GstVideoFilter.<br></span></div><div id="yui_3_16_0_ym19_1_1512653841324_28167"><span id="yui_3_16_0_ym19_1_1512653841324_28123"><br></span></div><div dir="ltr" id="yui_3_16_0_ym19_1_1512653841324_28131"><span id="yui_3_16_0_ym19_1_1512653841324_28123"><a href="https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/gst-libs/gst/video/gstvideofilter.c" class="" id="yui_3_16_0_ym19_1_1512653841324_28129">https://cgit.freedesktop.org/gstreamer/gst-plugins-base/tree/gst-libs/gst/video/gstvideofilter.c</a></span></div><br><div id="yui_3_16_0_ym19_1_1512653841324_28219">And, in any case, the gstvideofilter.c has code to make buffers writable.<br></div> <div class="qtdSeparateBR"><br><br></div><div class="yahoo_quoted" style="display: block;"> <div style="font-family: lucida console, sans-serif; font-size: 13px;"> <div style="font-family: HelveticaNeue, Helvetica Neue, Helvetica, Arial, Lucida Grande, sans-serif; font-size: 16px;"> <div dir="ltr"><font size="2" face="Arial"> Le Jeudi 7 décembre 2017 14h07, Jimmy De Pauw <jimmy@dcode.eu> a écrit :<br></font></div>  <br><br> <div class="y_msg_container"><div id="yiv7335211655"><div>Hello everyone,<div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">I am currently in the process of making a custom plugin that would alter frames from a video file or a stream.</div><div class="yiv7335211655">As i could gather the best base for this is to subclass BaseTransform.</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">The base code for this is :</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">*****</div><div class="yiv7335211655"><div class="yiv7335211655">class TfObjectDetection(GstBase.BaseTransform):</div><div class="yiv7335211655">    __gsttemplates__ = (</div><div class="yiv7335211655">        Gst.PadTemplate.new(</div><div class="yiv7335211655">            "src",</div><div class="yiv7335211655">            Gst.PadDirection.SRC,</div><div class="yiv7335211655">            Gst.PadPresence.ALWAYS,</div><div class="yiv7335211655">            Gst.Caps.from_string("video/x-raw,format=(string)RGB")),</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">        Gst.PadTemplate.new(</div><div class="yiv7335211655">            "sink",</div><div class="yiv7335211655">            Gst.PadDirection.SINK,</div><div class="yiv7335211655">            Gst.PadPresence.ALWAYS,</div><div class="yiv7335211655">            Gst.Caps.from_string("video/x-raw,format=(string)RGB"))</div><div class="yiv7335211655">    )</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">    def __init__(self):</div><div class="yiv7335211655">        GstBase.BaseTransform.__init__(self)</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">        self.set_passthrough(False)</div><div class="yiv7335211655">        self.set_in_place(False)</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">    def do_transform(self, inbuf, outbuf):</div><div class="yiv7335211655">        print("Tensorflow plugin    :   processing frame at timestamp(buffer):%s" % (Gst.TIME_ARGS(inbuf.pts)))</div><div class="yiv7335211655">        print("                         buffer size is :%s" % (inbuf.get_size()))</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">        * do stuff *</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">        outbuf.fill(0, data)</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">        return Gst.FlowReturn.OK</div></div><div class="yiv7335211655">*****</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">Nothing fancy but whatever i try : <span style="color:rgb(244, 244, 244);font-family:Monaco;font-size:10px;" class="yiv7335211655">(<unknown>:63739): GStreamer-</span><span style="font-family:Monaco;font-size:10px;color:rgb(213, 59, 211);" class="yiv7335211655">CRITICAL</span><span style="color:rgb(244, 244, 244);font-family:Monaco;font-size:10px;" class="yiv7335211655"> **: gst_buffer_fill: assertion 'gst_buffer_is_writable (buffer)' failed</span></div><div class="yiv7335211655">Trying in-place result in the same error so i really don’t know what i should do.</div><div class="yiv7335211655">I also tried to subclass Element but i cannot fathom how caps negotiations works and it always fail with a « non negotiated » error.</div><div class="yiv7335211655">I listened to queries and put a method like this :</div><div class="yiv7335211655"><pre style="background-color:#2b2b2b;color:#a9b7c6;font-family:'Menlo';font-size:9.0pt;" class="yiv7335211655"><span style="color:#cc7832;" class="yiv7335211655">def </span><span style="color:#ffc66d;" class="yiv7335211655">_src_query</span>(<span style="color:#94558d;" class="yiv7335211655">self</span><span style="color:#cc7832;" class="yiv7335211655">, </span>pad<span style="color:#cc7832;" class="yiv7335211655">, </span>parent<span style="color:#cc7832;" class="yiv7335211655">, </span>query):<br class="yiv7335211655">    <span style="color:#cc7832;" class="yiv7335211655">if </span>query.type == Gst.QueryType.CAPS:<br class="yiv7335211655">        <span style="color:#8888c6;" class="yiv7335211655">print</span>(<span style="color:#6a8759;" class="yiv7335211655">"Got query '" </span>+ Gst.QueryType.get_name(query.type) + <span style="color:#6a8759;" class="yiv7335211655">"' on pad '" </span>+ pad.get_name() + <span style="color:#6a8759;" class="yiv7335211655">"'"</span>)<br class="yiv7335211655">        query.set_caps_result(Gst.Caps.from_string(<span style="color:#6a8759;" class="yiv7335211655">"video/x-raw,format=(string)RGB,width=4096,height=2160,framerate=0/1"</span>))<br class="yiv7335211655">        <span style="color:#cc7832;" class="yiv7335211655">return True<br class="yiv7335211655"></span><span style="color:#cc7832;" class="yiv7335211655">    else</span>:<br class="yiv7335211655">        <span style="color:#cc7832;" class="yiv7335211655">return </span>pad.query_default(parent<span style="color:#cc7832;" class="yiv7335211655">, </span>query)</pre><div class="yiv7335211655">but i have no idea what i should do in there so the next element accept my source pad.</div></div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">Checking the C code for BaseTransform is way too complicated, after all my plugin used fixed caps since it only support RGB frame on its sink.</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">Version for gstreamer is 1.12.3 and it is installed on OSX using brew.</div><div class="yiv7335211655">Python is 3.6</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">I’ve been stuck on this for a week now and i don’t really know what to do.</div><div class="yiv7335211655">I could abandon Python and write everything in C but that would require all my frame processing code to be rewritten in C as well which i would rather avoid.</div><div class="yiv7335211655"><br class="yiv7335211655"></div><div class="yiv7335211655">I would be very grateful for any insight.</div><div class="yiv7335211655">Thanks</div><div class="yiv7335211655"><span style="color:rgb(244, 244, 244);font-family:Monaco;font-size:10px;" class="yiv7335211655"><br class="yiv7335211655"></span></div></div></div>_______________________________________________<br>gstreamer-devel mailing list<br><a ymailto="mailto:gstreamer-devel@lists.freedesktop.org" href="mailto:gstreamer-devel@lists.freedesktop.org">gstreamer-devel@lists.freedesktop.org</a><br><a href="https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel" target="_blank">https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel</a><br><br><br></div>  </div> </div>  </div></div></body></html>