This post was updated on .
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 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() class PipelineRunner(object): """Provides an easy way to run a pre-constructed Gstreamer pipeline much like gst-launch""" def __init__(self, pipeline): self.mainloop = GObject.MainLoop() self.err, self.dbg = None, None def on_error(_bus, message): self.err, self.dbg = message.parse_error() self.mainloop.quit() def on_warning(_bus, message): assert message.type == Gst.MessageType.WARNING _err, _dbg = message.parse_warning() sys.stderr.write("Warning: %s: %s\n%s\n" % (_err, _err.message, _dbg)) def on_eos(_bus, _message): pipeline.set_state(Gst.State.NULL) self.mainloop.quit() bus = pipeline.get_bus() bus.connect("message::eos", on_eos) bus.connect("message::error", on_error) bus.connect("message::warning", on_warning) bus.add_signal_watch() pipeline.set_state(Gst.State.PLAYING) self.pipeline = pipeline def run(self): self.mainloop.run() if self.err is not None: raise RuntimeError("Error running pipeline: %s\n\n%s" % (self.err, self.dbg)) def __del__(self): self.pipeline.set_state(Gst.State.NULL) self.pipeline.get_state(0) 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) My video capture card details Driver Info: Driver name : uvcvideo Card type : ezcap U3 capture: ezcap U3 capt Bus info : usb-0000:00:1d.0-1.5 Driver version : 4.15.18 Capabilities : 0x84200001 Video Capture Streaming Extended Pix Format Device Capabilities Device Caps : 0x04200001 Video Capture Streaming Extended Pix Format Media Driver Info: Driver name : uvcvideo Model : ezcap U3 capture: ezcap U3 capt Serial : Bus info : usb-0000:00:1d.0-1.5 Media version : 4.15.18 Hardware revision: 0x00000100 (256) Driver version : 4.15.18 Interface Info: ID : 0x03000002 Type : V4L Video Entity Info: ID : 0x00000001 (1) Name : ezcap U3 capture: ezcap U3 capt Function : V4L2 I/O Pad 0x01000004 : Sink Link 0x02000010: from remote pad 0x1000007 of entity 'Extension 4': Data, Enabled, Immutable Priority: 2 Video input : 0 (Camera 1: ok) Format Video Capture: Width/Height : 1920/1080 Pixel Format : 'MJPG' (Motion-JPEG) Field : None Bytes per Line : 0 Size Image : 4147200 Colorspace : sRGB Transfer Function : Default (maps to sRGB) YCbCr/HSV Encoding: Default (maps to ITU-R 601) Quantization : Default (maps to Full Range) Flags : Crop Capability Video Capture: Bounds : Left 0, Top 0, Width 1920, Height 1080 Default : Left 0, Top 0, Width 1920, Height 1080 Pixel Aspect: 1/1 Selection: crop_default, Left 0, Top 0, Width 1920, Height 1080, Flags: Selection: crop_bounds, Left 0, Top 0, Width 1920, Height 1080, Flags: Streaming Parameters Video Capture: Capabilities : timeperframe Frames per second: 30.000 (30/1) Read buffers : 0 brightness 0x00980900 (int) : min=0 max=255 step=1 default=128 value=128 contrast 0x00980901 (int) : min=0 max=255 step=1 default=128 value=128 saturation 0x00980902 (int) : min=0 max=255 step=1 default=128 value=128 hue 0x00980903 (int) : min=-32 max=31 step=1 default=0 value=0 -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list gstreamer-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
I have fixed above error by adding decodebin in pipeline command as follows
pipeline_command = "appsrc name=videosrc is-live=true caps=image/jpeg,width=1920,height=1080,framerate=30/1 ! queue ! decodebin ! videoconvert ! x264enc ! " \ "mpegtsmux ! " \ "hlssink location=/var/www/segment-%05d.ts " \ "playlist-location=/var/www/index.m3u8 max-files=10 " \ "target-duration=15 sync=false" But i got one more issue don't know this is the root cause or not for not getting .ts and .m3u8 file is not generated 0:00:00.177883765 15 0x557ed8a5a150 WARN ladspa gstladspa.c:507:plugin_init:<plugin91> no LADSPA plugins found, check LADSPA_PATH 0:00:00.239043179 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x120000: 'AVR (Audio Visual Research)' is not mapped 0:00:00.239055066 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x180000: 'CAF (Apple Core Audio File)' is not mapped 0:00:00.239069455 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x100000: 'HTK (HMM Tool Kit)' is not mapped 0:00:00.239076439 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xc0000: 'MAT4 (GNU Octave 2.0 / Matlab 4.2)' is not mapped 0:00:00.239096187 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xd0000: 'MAT5 (GNU Octave 2.1 / Matlab 5.0)' is not mapped 0:00:00.239100583 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x210000: 'MPC (Akai MPC 2k)' is not mapped 0:00:00.239106233 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0xe0000: 'PVF (Portable Voice Format)' is not mapped 0:00:00.239111183 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x160000: 'SD2 (Sound Designer II)' is not mapped 0:00:00.239119349 15 0x557ed8a5a150 WARN default gstsf.c:98:gst_sf_create_audio_template_caps: format 0x190000: 'WVE (Psion Series 3)' is not mapped check_hls_streaming 20200517 14:55:33 STEF[7] stef_hdmi| DEBUG| HDMI device open.[/dev/video0] starting hls live streamingwaiting for 600 seconds appsrc name=videosrc is-live=true caps=image/jpeg,width=1920,height=1080,framerate=30/1 ! queue ! decodebin ! videoconvert ! x264enc ! mpegtsmux ! hlssink location=/var/www/segment-%05d.ts playlist-location=/var/www/index.m3u8 max-files=10 target-duration=15 sync=false 0:00:00.941194930 7 0x7f2c6805bed0 FIXME default gstutils.c:3981:gst_pad_create_stream_id_internal:<videosrc:src> Creating random stream-id, consider implementing a deterministic way of creating a stream-id 0:00:00.943707430 7 0x7f2c6805be80 FIXME videodecoder gstvideodecoder.c:933:gst_video_decoder_drain_out:<jpegdec0> Sub-class should implement drain() 0:00:00.943762184 7 0x7f2c6805be80 FIXME videodecoder gstvideodecoder.c:933:gst_video_decoder_drain_out:<jpegdec0> Sub-class should implement drain() *0:00:01.317674270 7 0x7f2c6805be80 WARN videodecoder gstvideodecoder.c:2443:gst_video_decoder_chain:<jpegdec0> Received buffer without a new-segment. *Assuming timestamps start from 0. 0:00:01.317697268 7 0x7f2c6805be80 FIXME videodecoder gstvideodecoder.c:933:gst_video_decoder_drain_out:<jpegdec0> Sub-class should implement drain() To add i am not getting any error if i use same pipeline command in opencv cv2.VideoWriter function -- Sent from: http://gstreamer-devel.966125.n4.nabble.com/ _______________________________________________ gstreamer-devel mailing list [hidden email] https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel |
Free forum by Nabble | Edit this page |