Reputation: 141
I have below code which read the frame from video capture card and push those frames are gst buffer to appsrc element but when i run the code i am getting getting streaming stopped, reason not-negotiated (-4) error i am suspecting there is some issue with my caps assignement. Can someone help to point where i am doing mistake in my code
import sys
import gi
import os
import threading
import traceback
gi.require_version("Gst", "1.0")
from gi.repository import GObject, Gst # pylint:disable=wrong-import-order
Gst.init([])
class LiveStreamingDUT(object):
def __init__(self, display):
self.end_of_stream = False
self.vsrc = None
def __stream_dut(self):
try:
pipeline_command = "appsrc name=videosrc is-live=true block=true caps=image/jpeg,framerate=(fraction)30/1 ! videoconvert ! x264enc tune=zerolatency ! " \
"mpegtsmux ! " \
"hlssink location=/var/www/segment-%05d.ts " \
"playlist-location=/var/www/index.m3u8 max-files=20 " \
"target-duration=15"
print(pipeline_command)
pipeline = Gst.parse_launch(pipeline_command)
self.vsrc = pipeline.get_by_name('videosrc')
r = PipelineRunner(pipeline)
thread = threading.Thread(target=r.run)
thread.daemon = True
thread.start()
writerThread = threading.Thread(target=self._appsrc_push_data, name='gstreamerpushdata')
writerThread.start()
except:
print('error during streaming content')
print("teardown: Exiting (GLib mainloop %s)" % (
"is still alive!" if thread.isAlive() else "ok"))
def _appsrc_push_data(self):
try:
while (self.end_of_stream == False):
try:
ret, data = <read frame from hdmi capture card and return in numpy array>
buf = self.ndarray_to_gst_buffer(data)
self.vsrc.emit('push-buffer', buf)
except:
traceback.print_exc()
print("Error reading HDMI data")
self.end_of_stream = True
break
except:
pass
finally:
pass
def ndarray_to_gst_buffer(self, array):
"""Converts numpy array to Gst.Buffer"""
return Gst.Buffer.new_wrapped(array.tobytes())
def stream_dut(self):
self.__stream_dut()
Getting error message
Exception in thread Thread-1:
Traceback (most recent call last):
File "/usr/local/lib/python3.7/threading.py", line 926, in _bootstrap_inner
self.run()
File "/usr/local/lib/python3.7/threading.py", line 870, in run
self._target(*self._args, **self._kwargs)
File "./display/gst_live_stream.py", line 111, in run
(self.err, self.dbg))
RuntimeError: Error running pipeline: gst-stream-error-quark: Internal data stream error. (1)
gstbasesrc.c(3055): gst_base_src_loop (): /GstPipeline:pipeline0/GstAppSrc:videosrc:
streaming stopped, reason not-negotiated (-4)
Upvotes: 0
Views: 9735
Reputation: 2743
There seems to be an error in the initial part of your pipeline
appsrc (...) caps=image/jpeg,framerate=(fraction)30/1 ! videoconvert
Your appsrc
element seems to be outputting a motion JPEG stream and trying to feed that to the videoconvert
element, which only takes a raw video stream as input. Probably this can be just solved by putting a decodebin
inbetween, which will decode the JPEG frames for you.
Upvotes: 0