在GStreamer中使用ximagesrc和python绑定的视频流

2024-05-26 20:45:11 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试获取我的桌面屏幕,并流到我的笔记本电脑。 为此,我写了以下代码。但似乎他们没有连接或不发送数据。在

这是我的密码

在发送方

#!/usr/bin/env python
# coding: latin-1
import sys
import os
import gtk
import time
import datetime
import gobject, pygst
pygst.require("0.10")
import gst
pipeline = gst.Pipeline("client")
source = gst.element_factory_make("ximagesrc", "source")
source.set_property("use-damage", "false")
pipeline.add(source)
def new_mux_pad(mux, pad, islast):
    pad.link(mux.get_pad("mpeg"))
    mux = gst.element_factory_make("dvddemux", "mux")
    mux.connect("new-muxed-pad", new_mux_pad)
    pipeline.add(mux)
    src.link(mux)
def new_mpeg_pad(mpg, pad, islast):
    pad.link(mpeg.get_pad("theora"))
    mpeg = gst.element_factory_make("mpeg2dec", "mpeg")
    mpeg.connect("new-mpeged-pad", new_mpeg_pad)
    pipeline.add(mpeg)
    mux.link(mpeg)
def new_theoraenc_pad(thr, pad, islast):
    pad.link(theora.get_pad("ogg"))
    theora = gst.element_factory_make("theoraenc", "theora")
    theora.connect("new-theoraenced-pad", new_theoraenc_pad)
    pipeline.add(theora)
    mpeg.link(theora)
def new_ogg_pad(og, pad, islast):
    ogg = gst.element_factory_make("oggmux", "ogg")
    ogg.connect("new-ogged-pad", new_ogg_pad)
    pipeline.add(ogg)
    theora.link(ogg)
    client = gst.element_factory_make("tcpclientsink", "client")
    pipeline.add(client)
    client.set_property("host", "10.3.100.207")
    client.set_property("port", 8080)
    ogg.link(client)
pipeline.set_state(gst.STATE_PLAYING)
loop = gobject.MainLoop()
loop.run()

我的接收器的代码是:

^{pr2}$

当我运行这些代码时,我没有得到任何输出。在


Tags: importclientaddnewmakepipelinefactorylink

热门问题