• NVIDIA V100
• DeepStream5.0
• 7.0.0-1+cuda10.2
• 440.64
Running deepstream_test_1.py, but the pipeline seems to freeze after creation (does not react to Ctrl+C). Empirically I was able to discover that the culprit seems to be nvv4l2decoder, or more precisely - the absence of qtdemux before it (I was testing on provided .mp4 files). Below is a minimal examples that reproduces the problem
(to run: python3 sample.py <path_to_mp4>)
import sys
import io
import gi
gi.require_version("Gst", "1.0")
from gi.repository import GObject, Gst
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
# gst-launch-1.0 -e videotestsrc ! queue ! x264enc ! avimux ! filesink location=test.avi
# gst-launch-1.0 -e filesrc location=../../../samples/streams/sample_720p.mp4 ! h264parse ! nvv4l2decoder ! fakesink
def make_elm_or_print_err(factoryname, name, printedname, detail=""):
""" Creates an element with Gst Element Factory make.
Return the element if successfully created, otherwise print
to stderr and return None.
"""
print("Creating", printedname)
elm = Gst.ElementFactory.make(factoryname, name)
if not elm:
sys.stderr.write("Unable to create " + printedname + " \n")
if detail:
sys.stderr.write(detail)
return elm
def main(args):
GObject.threads_init()
Gst.init(None)
# Create gstreamer elements
# Create Pipeline element that will form a connection of other elements
print("Creating Pipeline \n ")
pipeline = Gst.Pipeline()
source = make_elm_or_print_err("filesrc", "file-source", "Source")
source.set_property("location", args[1])
parser = make_elm_or_print_err("h264parse", "h264-parser", "H264Parser")
decoder = make_elm_or_print_err("nvv4l2decoder", "h264-decoder", "H264Decoder")
sink = make_elm_or_print_err("fakesink", "fake-sink", "Sink")
pipeline.add(source)
pipeline.add(parser)
pipeline.add(decoder)
pipeline.add(sink)
source.link(parser)
parser.link(decoder)
decoder.link(sink)
loop = GObject.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect("message", bus_call, loop)
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except:
pass
# cleanup
pipeline.set_state(Gst.State.NULL)
if __name__=='__main__':
sys.exit(main(sys.argv))
However, if I add qtdemux after source and before parser, the pipeline finishes:
...
demux = make_elm_or_print_err("qtdemux", "qtdemux", "QTDemux")
...
pipeline.add(demux)
...
source.link(demux)
def demux_pad_added(demux, pad):
if pad.name == 'video_0': # We expect exactly first one video stream
pad.link(parser.get_static_pad("sink"))
demux.connect("pad-added", demux_pad_added)
I am not very familiar with how gStreamer works and am not sure whether qtdemux is really needed, so am I missing something?