我正在将一个程序从 pygst 0.10 移植到 1.0,但我遇到了管道问题。我在 0.10 版本中使用并且运行良好的管道是:
udpsrc name=src ! tsparse ! tsdemux ! queue ! ffdec_h264 max-threads=0 ! identity ! xvimagesink force-aspect-ratio=True name=video
对于 1.0 版本,管道应该类似于:
udpsrc name=src ! tsparse ! tsdemux ! queue ! avdec_h264 ! videoconvert ! xvimagesink force-aspect-ratio=True name=video
代码是:
self.pipeline = Gst.Pipeline()
self.udpsrc = Gst.ElementFactory.make('udpsrc', 'src')
self.pipeline.add(self.udpsrc)
self.udpsrc.set_property("socket", Gio.Socket().new_from_fd(self.videosocket.fileno()))
self.tsparse = Gst.ElementFactory.make("tsparse", None)
self.pipeline.add(self.tsparse)
self.demux = Gst.ElementFactory.make('tsdemux', None)
self.pipeline.add(self.demux)
self.queue = Gst.ElementFactory.make('queue', None)
self.pipeline.add(self.queue)
self.h264 = Gst.ElementFactory.make('avdec_h264', None)
self.pipeline.add(self.h264)
self.videoconvert = Gst.ElementFactory.make('videoconvert', None)
self.pipeline.add(self.videoconvert)
self.imagesink = Gst.ElementFactory.make('xvimagesink', None)
self.pipeline.add(self.imagesink)
self.udpsrc.link(self.tsparse)
self.tsparse.link(self.demux)
self.demux.link(self.queue)
self.queue.link(self.h264)
self.h264.link(self.videoconvert)
self.videoconvert.link(self.imagesink)
我已经设置了调试标志和输出 iS:
GST_EVENT gstevent.c:709:gst_event_new_segment: creating segment event time segment start=0:00:00.000000000, stop=99:99:99.999999999, rate=1,000000, applied_rate=1,000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.000000000, duration 99:99:99.999999999
0:00:06.241739369 5576 0x2f1c590 INFO basesrc gstbasesrc.c:2772:gst_base_src_loop:<src> marking pending DISCONT
0:00:06.241751688 5576 0x2f1c590 INFO mpegtspacketizer mpegtspacketizer.c:770:mpegts_try_discover_packet_size: have packetsize detected: 188 bytes
0:00:06.241786466 5576 0x2f1c590 INFO mpegtsbase mpegtsbase.c:726:mpegts_base_apply_pat:<mpegtsparse2-0> PAT
0:00:06.242321432 5576 0x2f1c590 INFO GST_ELEMENT_PADS gstelement.c:897:gst_element_get_static_pad: found pad mpegtsparse2-0:sink
0:00:06.252539174 5576 0x2f1c590 INFO GST_EVENT gstevent.c:628:gst_event_new_caps: creating caps event video/mpegts, systemstream=(boolean)true, packetsize=(int)188
0:00:06.252604078 5576 0x2f1c590 INFO GST_EVENT gstevent.c:709:gst_event_new_segment: creating segment event time segment start=0:00:00.000000000, stop=99:99:99.999999999, rate=1,000000, applied_rate=1,000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.000000000, duration 99:99:99.999999999
0:00:06.252655518 5576 0x2f1c590 INFO mpegtspacketizer mpegtspacketizer.c:770:mpegts_try_discover_packet_size: have packetsize detected: 188 bytes
0:00:06.252693109 5576 0x2f1c590 INFO mpegtsbase mpegtsbase.c:726:mpegts_base_apply_pat:<tsdemux0> PAT
0:00:06.252856437 5576 0x2f1c590 INFO GST_ELEMENT_PADS gstelement.c:897:gst_element_get_static_pad: found pad tsdemux0:sink
0:00:06.252870522 5576 0x2f1c590 INFO GST_EVENT gstevent.c:628:gst_event_new_caps: creating caps event audio/mpeg, mpegversion=(int)1
0:00:06.252894869 5576 0x2f1c590 WARN default descriptions.c:612:format_info_get_desc: Unexpected MPEG-1 layer in audio/mpeg, mpegversion=(int)1
0:00:06.252931277 5576 0x2f1c590 INFO GST_ELEMENT_PADS gstelement.c:897:gst_element_get_static_pad: found pad tsdemux0:sink
0:00:06.252940534 5576 0x2f1c590 INFO GST_EVENT gstevent.c:628:gst_event_new_caps: creating caps event video/x-h264, stream-format=(string)byte-stream, alignment=(string)nal
0:00:06.252997433 5576 0x2f1c590 INFO GST_ELEMENT_PADS gstelement.c:646:gst_element_add_pad:<tsdemux0> adding pad 'audio_0041'
0:00:06.253006343 5576 0x2f1c590 INFO GST_EVENT gstevent.c:709:gst_event_new_segment: creating segment event time segment start=0:00:00.000000000, stop=99:99:99.999999999, rate=1,000000, applied_rate=1,000000, flags=0x00, time=0:00:00.000000000, base=0:00:00.000000000, position 0:00:00.000000000, duration 99:99:99.999999999
0:00:06.253348125 5576 0x2f1c590 INFO GST_ELEMENT_PADS gstelement.c:646:gst_element_add_pad:<tsdemux0> adding pad 'video_0040'
0:00:06.253394366 5576 0x2f1c590 INFO basesrc gstbasesrc.c:2785:gst_base_src_loop:<src> pausing after gst_pad_push() = not-linked
0:00:06.253408940 5576 0x2f1c590 WARN basesrc gstbasesrc.c:2865:gst_base_src_loop:<src> error: Internal data flow error.
0:00:06.253413835 5576 0x2f1c590 WARN basesrc gstbasesrc.c:2865:gst_base_src_loop:<src> error: streaming task paused, reason not-linked (-1)
0:00:06.253425400 5576 0x2f1c590 INFO GST_ERROR_SYSTEM gstelement.c:1835:gst_element_message_full:<src> posting message: Internal data flow error.
0:00:06.253439614 5576 0x2f1c590 INFO GST_ERROR_SYSTEM gstelement.c:1858:gst_element_message_full:<src> posted error message: Internal data flow error.
0:00:06.253513306 5576 0x2f1c590 INFO GST_ELEMENT_PADS gstelement.c:766:gst_element_remove_pad:<tsdemux0> removing pad 'audio_0041'
0:00:06.253531993 5576 0x2f1c590 INFO GST_ELEMENT_PADS gstelement.c:766:gst_element_remove_pad:<tsdemux0> removing pad 'video_0040'
('on_error():', (GError('Internal data flow error.',), 'gstbasesrc.c(2865): gst_base_src_loop (): /GstPipeline:pipeline0/GstUDPSrc:src:\nstreaming task paused, reason not-linked (-1)'))
0:00:06.253551147 5576 0x2f1c590 INFO task gsttask.c:300:gst_task_func:<src:src> Task going to paused