Gstreamer pipleline的CPU使用率和内存

Gstreamer pipleline的CPU使用率和内存,gstreamer,rtp,x264,Gstreamer,Rtp,X264,我正在使用gstreamer从网络摄像头捕获视频,用x264编码,然后用gstrtpbin流式传输。它工作得很好。然而,它使用了我所有四个内核的50%和大量内存。我能做些什么来降低CPU和内存的使用率吗?这是管道 pipeline_description = "gstrtpbin latency=0 max-latency=100 drop-on-latency=true use-pipeline-clock=true ntp-sync=true name=rtpbin " \

我正在使用gstreamer从网络摄像头捕获视频,用x264编码,然后用gstrtpbin流式传输。它工作得很好。然而,它使用了我所有四个内核的50%和大量内存。我能做些什么来降低CPU和内存的使用率吗?这是管道

pipeline_description = "gstrtpbin latency=0 max-latency=100 drop-on-latency=true use-pipeline-clock=true ntp-sync=true name=rtpbin " \
        "autovideosrc ! video/x-raw-yuv,width=640,height=480,framerate=30/1 ! " \
        "tee name=t_vid ! queue ! fpsdisplaysink name=fpssink text-overlay=false video-sink=xvimagesink signal-fps-measurements=true t_vid. ! " \
        "queue ! videorate ! ffmpegcolorspace ! x264enc pass=qual tune=zerolatency quantizer=40 ! queue ! rtph264pay ! rtpbin.send_rtp_sink_0 " \
        "rtpbin.send_rtp_src_0 ! udpsink port=%d host=%s sync=false async=false rtpbin.send_rtcp_src_0 ! " \
        "udpsink port=%d host=%s sync=false async=false name=vrtcpsink udpsrc port=%d ! " \
        "rtpbin.recv_rtcp_sink_0 autoaudiosrc ! queue ! audioresample ! audioconvert ! alawenc ! rtppcmapay ! rtpbin.send_rtp_sink_1 " \
        "rtpbin.send_rtp_src_1 ! udpsink port=%d host=%s sync=false async=false rtpbin.send_rtcp_src_1 ! " \
        "udpsink port=%d host=%s sync=false async=false udpsrc port=%d ! rtpbin.recv_rtcp_sink_1" % (VRTP_SEND_PORT, DEST,
        VRTCP_SEND_PORT, DEST, VRTCP_RECV_PORT, ARTP_SEND_PORT, DEST, ARTCP_SEND_PORT, DEST, ARTCP_RECV_PORT)

我会运行oprofile/sysprof来查看哪个代码是最大的违规者。通过使用较少的抽象接收器和源(例如,直接使用xvimagesink而不是fpsdisplaysink),您可能可以节省一些钱。如果可以,请避免ffmpegcolorspace(原则上,颜色空间转换,如果不需要,元素不会做任何事情,只会导致很少的开销)。

如果不需要帧速率计算和更高的覆盖,可以通过这种方式减少一些CPU消耗,但正如joeforker所指出的,h264在计算上相当密集,因此,尽管您的管道中进行了所有优化,我怀疑您是否会看到超过10-15%的改进,除非其中一个元素是有缺陷的。这就是ensonic对评测的评论非常有用的地方,特别是如果您愿意重写某些元素,即用您自己的元素替换所提供的元素。

我也看到了这个问题-使用sync=false似乎会触发100%的CPU。还有另外一条线索谈到这一点。HTH

VGA分辨率下每秒30帧编码到h.264中的计算量很大@joeforker:这确实是一个很好的性能解决方案,因为我意识到了这一点,并且我看到了HDMI渲染的不同之处。队列都使用内存。您可以移动它们或限制它们的大小。