gstreamer videotestsrc状态res

2024-09-28 19:10:10 发布

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

我有一个带有videotestsrc的gstreamer管道。我的计划是更改管道,但不丢失videotestsrc的播放位置。我当前的代码更改了管道,并用radioactv效果更改了quarktv效果,但videotestsrc在恢复管道后从头开始。有没有办法防止这种情况发生?在

from gi.repository import Gst
import time
import os

os.environ["GST_DEBUG"] = "3"
Gst.init()
pipeline = Gst.Pipeline.new()

def gen_cb(a, b, *c):
    print "gen_cb", a, b, c
    return Gst.PadProbeReturn.OK

# creating elements
vs = Gst.ElementFactory.make('videotestsrc')
vs.set_property('pattern', 18)
vs.set_property('is-live', 1)
pipeline.add(vs)

vc = Gst.ElementFactory.make('videoconvert')
pipeline.add(vc)

av = Gst.ElementFactory.make('autovideosink')
pipeline.add(av)

quark = Gst.ElementFactory.make('quarktv')
pipeline.add(quark)

radioactv = Gst.ElementFactory.make('radioactv')

q1 = Gst.ElementFactory.make('queue')
pipeline.add(q1)

# linking
vs.link(q1)
q1.link(quark)
quark.link(vc)
vc.link(av)

# starting
pipeline.set_state(Gst.State.PLAYING)

# sleep some time
time.sleep(2)

# modify
probe_id = q1.pads[1].add_probe(Gst.PadProbeType.BLOCK_DOWNSTREAM, gen_cb)
quark.unlink(q1)
pipeline.remove(quark)
quark.set_state(Gst.State.NULL)
pipeline.add(radioactv)
q1.link(radioactv)
radioactv.link(vc)
radioactv.set_state(Gst.State.PLAYING)
q1.pads[1].remove_probe(probe_id)

# wait until end
time.sleep(4)

Tags: addmake管道pipelinetimelinkvsset
1条回答
网友
1楼 · 发布于 2024-09-28 19:10:10

它看起来像是一个bug,请将它归档到https://bugzilla.gnome.org/enter_bug.cgi?product=GStreamer

当您修改管道时,会生成一个“重新配置”事件,以便元素适应可能的新配置(可能需要不同的格式/分辨率)。作为此操作的一部分,videotestsrc似乎也在重置其内部状态,以便图形从“0”重新启动。在

相关问题 更多 >