当我们设置suburi

时间:2018-04-09 10:58:00

标签: gstreamer python-gstreamer

        self.player.set_state(Gst.State.READY)
        self.player.set_property("suburi", name)
        self.player.set_property("subtitle-font-desc", "Sans, 18")
        self.player.set_state(Gst.State.PLAYING)

单击某个按钮时,上述代码会为播放状态下的视频设置字幕。 我使用上面的代码将字幕设置为一个已经处于PLAYING状态的视频,当点击某个按钮时。当我点击它时,会显示字幕;但视频不会从当前位置恢复;它重新开始。我也试过以下,

        _, duration = self.player.query_duration(Gst.Format.TIME)
        print(duration)
        self.player.set_state(Gst.State.NULL)
        self.player.set_property("uri", self.filename)
        self.player.set_property("suburi", name)
        self.player.set_property("subtitle-font-desc", "Sans, 18")
        self.player.set_state(Gst.State.PLAYING)
        self.player.seek_simple(Gst.Format.TIME, Gst.SeekFlags.FLUSH, duration)

即使这样也不寻求。有没有其他方法来设置suburi而不重新启动视频?

1 个答案:

答案 0 :(得分:0)

弗洛里安在评论中指出,没有必要改变国家 只需设置属性suburi,您也可以查看设置flags属性。
如:

self.player.set_property('flags', self.GST_VIDEO|self.GST_AUDIO|self.GST_TEXT|self.GST_SOFT_VOLUME|self.GST_DEINTERLACE)

当字幕开启时 和

self.player.set_property('flags', self.GST_VIDEO|self.GST_AUDIO|self.GST_SOFT_VOLUME|self.GST_DEINTERLACE)

当字幕关闭

GST属性声明为:

self.GST_VIDEO         = (1 << 0)
self.GST_AUDIO         = (1 << 1)
self.GST_TEXT          = (1 << 2)
self.GST_VIS           = (1 << 3)
self.GST_SOFT_VOLUME   = (1 << 4)
self.GST_NATIVE_AUDIO  = (1 << 5)
self.GST_NATIVE_VIDEO  = (1 << 6)
self.GST_DOWNLOAD      = (1 << 7)
self.GST_BUFFERING     = (1 << 8)
self.GST_DEINTERLACE   = (1 << 9)
self.GST_SOFT_COLORBALANCE = (1 << 10)

请参阅:https://gstreamer.freedesktop.org/data/doc/gstreamer/head/gst-plugins-base-plugins/html/gst-plugins-base-plugins-playbin.html#GstPlayBin--flags