• Hardware Platform : DGPU
• DeepStream Version : 6.2.0 **
• TensorRT Version : 8.5.2.2
• NVIDIA GPU Driver Version : 530.30.02
• Issue Type
Input and output fps is not matching when used with the nvstreammux plugin
• code for reproducibility :
Pipeline only with decoder → encoder in which the input and output video FPS are matching
import time
import sys
import os
import gi
gi.require_version(‘Gst’, ‘1.0’)
from gi.repository import GLib, Gst
from common.bus_call import bus_call
import time
import pyds
def cb_new_pad(qtdemux, pad, data):
h264parser = data
name = pad.get_name()
if “video_0” in name and pad.link(h264parser.get_static_pad(“sink”)):
print(f"Could not link {name} pad of qtdemux to sink pad of h264parser")
Gst.init(None)
pipeline = Gst.Pipeline()
source = Gst.ElementFactory.make(“filesrc”, “file-source”)
demux = Gst.ElementFactory.make(“qtdemux”, “demux”)
h264parser = Gst.ElementFactory.make(“h264parse”, “h264-parser”)
decoder = Gst.ElementFactory.make(“nvv4l2decoder”, “nvv4l2-decoder”)
streammux = Gst.ElementFactory.make(“nvstreammux”, “Stream-muxer”)
encoder = Gst.ElementFactory.make(“nvv4l2h264enc”, “nvv4l2-h264-encoder”)
h264parser2 = Gst.ElementFactory.make(“h264parse”, “h264-parser2”)
qtmux = Gst.ElementFactory.make(“qtmux”, “qtmux”)
sink = Gst.ElementFactory.make(“filesink”, “filesink”)
opFileName = “sample_1.mp4”
sink.set_property(“location”, opFileName)
source.set_property(‘location’, <“.mp4”>) # replace it with your mp4 file
streammux.set_property(‘batch-size’, 1)
if os.environ.get(‘USE_NEW_NVSTREAMMUX’) != ‘yes’:
streammux.set_property(‘width’, 1280)
streammux.set_property(‘height’, 720)
pipeline.add(source)
pipeline.add(demux)
pipeline.add(h264parser)
pipeline.add(decoder)
pipeline.add(streammux)
pipeline.add(encoder)
pipeline.add(h264parser2)
pipeline.add(qtmux)
pipeline.add(sink)
print(“Linking elements in the Pipeline \n”)
source.link(demux)
demux.connect(“pad-added”, cb_new_pad, h264parser)
h264parser.link(decoder)
decoder.link(encoder)
encoder.link(h264parser2)
h264parser2.link(qtmux)
qtmux.link(sink)
loop = GLib.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect (“message”, bus_call, loop)
print(“Starting pipeline (First Time)\n”)
time_run_pipeline_start = time.time()
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except:
pass
Pipeline with decoder-> nvstreammux ->encoder in which the input and output video FPS are not matching
import time
import sys
import os
import gi
gi.require_version(‘Gst’, ‘1.0’)
from gi.repository import GLib, Gst
from common.bus_call import bus_call
import time
import pyds
def cb_new_pad(qtdemux, pad, data):
h264parser = data
name = pad.get_name()
if “video_0” in name and pad.link(h264parser.get_static_pad(“sink”)):
print(f"Could not link {name} pad of qtdemux to sink pad of h264parser")
Gst.init(None)
pipeline = Gst.Pipeline()
source = Gst.ElementFactory.make(“filesrc”, “file-source”)
demux = Gst.ElementFactory.make(“qtdemux”, “demux”)
h264parser = Gst.ElementFactory.make(“h264parse”, “h264-parser”)
decoder = Gst.ElementFactory.make(“nvv4l2decoder”, “nvv4l2-decoder”)
streammux = Gst.ElementFactory.make(“nvstreammux”, “Stream-muxer”)
encoder = Gst.ElementFactory.make(“nvv4l2h264enc”, “nvv4l2-h264-encoder”)
h264parser2 = Gst.ElementFactory.make(“h264parse”, “h264-parser2”)
qtmux = Gst.ElementFactory.make(“qtmux”, “qtmux”)
sink = Gst.ElementFactory.make(“filesink”, “filesink”)
opFileName = “sample_1.mp4”
sink.set_property(“location”, opFileName)
source.set_property(‘location’, <“.mp4”>) # replace it with your mp4 file
streammux.set_property(‘batch-size’, 1)
if os.environ.get(‘USE_NEW_NVSTREAMMUX’) != ‘yes’:
streammux.set_property(‘width’, 1280)
streammux.set_property(‘height’, 720)
pipeline.add(source)
pipeline.add(demux)
pipeline.add(h264parser)
pipeline.add(decoder)
pipeline.add(streammux)
pipeline.add(encoder)
pipeline.add(h264parser2)
pipeline.add(qtmux)
pipeline.add(sink)
print(“Linking elements in the Pipeline \n”)
source.link(demux)
demux.connect(“pad-added”, cb_new_pad, h264parser)
h264parser.link(decoder)
sinkpad = streammux.get_request_pad(“sink_0”)
if not sinkpad:
sys.stderr.write(" Unable to get the sink pad of streammux \n")
srcpad = decoder.get_static_pad(“src”)
if not srcpad:
sys.stderr.write(" Unable to get source pad of decoder \n")
srcpad.link(sinkpad)
streammux.link(encoder)
encoder.link(h264parser2)
h264parser2.link(qtmux)
qtmux.link(sink)
loop = GLib.MainLoop()
bus = pipeline.get_bus()
bus.add_signal_watch()
bus.connect (“message”, bus_call, loop)
print(“Starting pipeline (First Time)\n”)
time_run_pipeline_start = time.time()
pipeline.set_state(Gst.State.PLAYING)
try:
loop.run()
except:
pass
• Requirement details
- This is sample working code snippet provided.
- nvstreammux is used in prior to nvinfer in the actual pipeline. Upon experimentation we have corned the issue with nvstreammux causing the FPS variation
- Please suggest methods in which we can maintain the same FPS for output video.
Eg : When a video with 18.57FPS is passed to the pipeline with
decoder-> nvstreammux ->encoder : Its providing a fps of 30.15,
But the same video passed to the pipeline with
decoder->encoder : Its providing the same FPS as input