首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Kivy:将延迟和延时参数传递给GstPlayer视频流小部件。

Kivy:将延迟和延时参数传递给GstPlayer视频流小部件。
EN

Stack Overflow用户
提问于 2019-01-14 04:33:41
回答 1查看 356关注 0票数 0

我希望扩展Kivy's视频小部件的功能。

使用以下RTSP代码播放RTSP视频流时,延迟时间为几秒钟。我想将延迟减少到100ms周围。

videostreaming.py:

代码语言:javascript
复制
from kivy.app import App
from kivy.lang import Builder
from kivy.uix.boxlayout import BoxLayout
import os.path

path_to_kv = os.path.join(os.path.dirname(__file__), 'videostreaming.kv')
Builder.load_file(path_to_kv)


class VideoStreaming(BoxLayout):
    pass


class TestApp(App):
    def build(self):
        root_widg = VideoStreaming()
        return root_widg


if __name__ == '__main__':
    TestApp().run()

videostreaming.kv:

代码语言:javascript
复制
<VideoStreaming>
    orientation: 'vertical'
    Video:
        source: "rtsp://192.168.1.88:554"
        state: 'play'

在命令提示符中可以通过运行以下命令来实现所需的低延迟:

代码语言:javascript
复制
$ .\gst-launch-1.0 -v playbin uri=rtsp://192.168.1.88:554 drop-on-latency=true latency=100

我想修改Kivy中的GstPlayer视频模块的行为,以允许传递“拖放-延迟=真”和"latency=100“参数。

相关的Kivy源代码在这里:gstplayer.pyx#L237-L256

Q1.如何子类GstPlayer Cython模块,以包括对延迟和拖放延迟参数的访问?

我认为子类应该重写load()方法,如下所示:

代码语言:javascript
复制
# import GstPlayer module to be subclassed
from kivy.lib.gstplayer cimport GstPlayer

# define subclass
cdef class LowLatencyGst(GstPlayer):

    #override load() method
    def load(self):
        # run parent's load() method
        super(LowLatencyGst, self).load()

        # set required attributes: latency = 100, drop-on-latency = True
        # Unconfirmed whether these commands are correctly named
        g_object_set_int(self.appsink, 'latency', 100)
        g_object_set_int(self.appsink, 'drop-on-latency', 1)

注意:试图编译上述代码是不成功的。这是伪码。

Q2.如何将上述子类集成为视频小部件的CoreVideo提供程序?

EN

回答 1

Stack Overflow用户

发布于 2019-01-16 00:55:48

以下提交提供了一个硬编码的解决方案来指定延迟值和拖放延迟值:https://github.com/sabarlow/kivy/commit/846e3147db4ac784c1aa4d02f47666716fb57644

在\kivy\lib\gstplayer_gstplayer.pyx:265中添加了以下代码行

代码语言:javascript
复制
g_object_set_int(self.pipeline, 'drop-on-latency', self.drop_on_latency)
g_object_set_int(self.pipeline, 'latency', self.latency)

用\kivy\lib\gstplayer_gstplayer.pyx:184设置

代码语言:javascript
复制
cdef int latency, drop_on_latency

在同一档案中:

代码语言:javascript
复制
def __init__(self, uri, sample_cb=None, eos_cb=None, message_cb=None, latency=500, drop_on_latency=1):
        super(GstPlayer, self).__init__()
        self.uri = uri
        self.sample_cb = sample_cb
        self.eos_cb = eos_cb
        self.message_cb = message_cb
        self.latency = latency
        self.drop_on_latency = drop_on_latency

然后Kivy被重新编译。

这不允许从Kivy的视频小部件中传递延迟和拖放延迟的值。有人能建议如何使这件事成功吗?

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/54175833

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档