Please provide complete information as applicable to your setup.
• Hardware Platform (RTX 2080 ti)
• Operating System (Ubuntu 20.04)
• NVIDIA GPU Driver Version (455.38)
• Issue Type(question)
Hi folks!
I am trying to build a gstreamer pipeline that starts with ‘filesrc’ (because the program I am building would take an rtsp stream or elementary h264 stream) and ends with ‘appsink’ (because I want access to the buffer so I can operate on each frame on the fly). This is what I have been able to come up with so far: ‘gst-launch-1.0 filesrc location=sample.264 ! decodebin ! videoconvert ! appsink wait-on-eos=false drop=true max-buffers=60’; it plays the file for the duration, then frees the pipeline okay, but there is no display. When I implement the same pipeline as a python script, I get the following error:
Error: gst-stream-error-quark: Internal data stream error. (1): gstbaseparse.c(3634): gst_base_parse_loop (): /GstPipeline:pipeline0/GstDecodeBin:decoder/GstH264Parse:h264parse0:
streaming stopped, reason not-linked (-1)
I am really confused here, is there something wrong with my pipeline or the python implementation? Your help would be much appreciated. Here is my python script:
****************************************
import sys
import gi
gi.require_version('Gst', '1.0')
from gi.repository import GObject, Gst, GLib
def bus_call(bus, message, loop):
t = message.type
if t == Gst.MessageType.EOS:
sys.stdout.write("End-of-stream\n")
loop.quit()
elif t==Gst.MessageType.WARNING:
err, debug = message.parse_warning()
sys.stderr.write("Warning: %s: %s\n" % (err, debug))
elif t == Gst.MessageType.ERROR:
err, debug = message.parse_error()
sys.stderr.write("Error: %s: %s\n" % (err, debug))
loop.quit()
return True
def main(args):
if len(args) != 2:
sys.stderr.write("usage: %s <media file or uri>\n" % args[0])
sys.exit(1)
# ~ GObject.threads_init()
Gst.init(None)
print("Creating Pipeline \n ")
pipeline = Gst.Pipeline()
if not pipeline:
sys.stderr.write(" Unable to create Pipeline \n")
print("Creating Source \n ")
source = Gst.ElementFactory.make("filesrc", "file-source")
if not source:
sys.stderr.write(" Unable to create Source \n")
print("Creating Decoder \n")
decoder = Gst.ElementFactory.make("decodebin", "decoder")
if not decoder:
sys.stderr.write(" Unable to create Decoder \n")
print("Creating Video Converter \n")
converter = Gst.ElementFactory.make("videoconvert", "converter")
if not converter:
sys.stderr.write(" Unable to create Video Converter \n")
print("Creating AppSink \n ")
sink = Gst.ElementFactory.make("appsink", 'NULL')
if not sink:
sys.stderr.write(" Unable to create AppSink \n")
print("Playing file %s " %args[1])
source.set_property('location', args[1])
sink.set_property('wait-on-eos', False)
sink.set_property('drop', True)
sink.set_property('max-buffers', 60)
caps = Gst.caps_from_string("video/x-raw, format=(string){BGR, GRAY8}; video/x-bayer,format=(string){rggb,bggr,grbg,gbrg}")
sink.set_property("caps", caps)
print("Adding elements to Pipeline \n")
pipeline.add(source)
pipeline.add(decoder)
pipeline.add(converter)
pipeline.add(sink)
print("Linking elements in the Pipeline \n")
source.link(decoder)
decoder.link(converter)
converter.link(sink)
# ~ loop = GObject.MainLoop()
loop = GLib.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect ("message", bus_call, loop)
print("Starting pipeline \n")
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except:
pass
pipeline.set_state(Gst.State.NULL)
if __name__ == '__main__':
sys.exit(main(sys.argv))
****************************************