本文整理汇总了Python中gi.repository.Gst.CLOCK_TIME_NONE属性的典型用法代码示例。如果您正苦于以下问题:Python Gst.CLOCK_TIME_NONE属性的具体用法?Python Gst.CLOCK_TIME_NONE怎么用?Python Gst.CLOCK_TIME_NONE使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.Gst
的用法示例。
在下文中一共展示了Gst.CLOCK_TIME_NONE属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: set_position
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def set_position(self, position):
if self.player is not None:
self.player.get_state(Gst.CLOCK_TIME_NONE)
self.player.set_state(Gst.State.PAUSED)
try:
assert self.player.seek_simple(Gst.Format.TIME,
Gst.SeekFlags.FLUSH,
position * Gst.SECOND)
self.player.get_state(Gst.CLOCK_TIME_NONE)
pos = self.player.query_position(Gst.Format.TIME)[1]
self.player.seek(self.speed, Gst.Format.TIME,
Gst.SeekFlags.FLUSH, Gst.SeekType.SET, pos,
Gst.SeekType.NONE, -1)
except AssertionError as e:
print(e)
self.player.set_state(Gst.State.PLAYING)
示例2: __init__
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def __init__(self):
GObject.GObject.__init__(self)
GstPbutils.pb_utils_init()
self._discoverer = GstPbutils.Discoverer.new(10 * Gst.SECOND)
self.is_playing = False
self.filepath = None
self._duration = Gst.CLOCK_TIME_NONE
self.asset = None
self._playbin = Gst.ElementFactory.make("playbin", "player")
bus = self._playbin.get_bus()
bus.add_signal_watch()
bus.connect("message::error", self.__on_bus_error)
bus.connect("message::eos", self.__on_bus_eos)
bus.connect("message::element", self.__on_bus_element)
bus.connect("message::stream-start", self._on_stream_start)
示例3: run
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def run(self):
# Start inference worker.
self.running = True
inf_worker = threading.Thread(target=self.inference_loop)
inf_worker.start()
render_worker = threading.Thread(target=self.render_loop)
render_worker.start()
# Run pipeline.
self.pipeline.set_state(Gst.State.PLAYING)
self.pipeline.get_state(Gst.CLOCK_TIME_NONE)
# We're high latency on higher resolutions, don't drop our late frames.
if self.overlaysink:
sinkelement = self.overlaysink.get_by_interface(GstVideo.VideoOverlay)
else:
sinkelement = self.pipeline.get_by_interface(GstVideo.VideoOverlay)
sinkelement.set_property('sync', False)
sinkelement.set_property('qos', False)
try:
Gtk.main()
except:
pass
# Clean up.
self.pipeline.set_state(Gst.State.NULL)
while GLib.MainContext.default().iteration(False):
pass
with self.condition:
self.running = False
self.condition.notify_all()
inf_worker.join()
render_worker.join()
示例4: get_status
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def get_status(self):
'''
Get the status of the player
'''
if self.player is not None:
if self.player.get_state(Gst.CLOCK_TIME_NONE)[1] ==\
Gst.State.PLAYING:
return Status.PLAYING
elif self.player.get_state(Gst.CLOCK_TIME_NONE)[1] ==\
Gst.State.PAUSED:
return Status.PAUSED
return Status.STOPPED
示例5: play
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def play(self):
'''
Play the player
'''
if self.player is not None:
self.player.set_state(Gst.State.PLAYING)
self.player.get_state(Gst.CLOCK_TIME_NONE)
self.player.get_by_name('removesilence').set_property(
'remove', self.removesilence)
self.player.get_by_name('volume').set_property('volume',
self.volume)
self.player.get_by_name('amplification').set_property(
'amplification', self.amplification)
equalizer = self.player.get_by_name('equalizer')
for i in range(0, 18):
band = 'band{0}'.format(i)
if band in self.equalizer.keys():
equalizer.get_child_by_index(i).set_property(
'gain', self.equalizer[band])
else:
equalizer.get_child_by_index(i).set_property(
'gain', 0)
pos = self.player.query_position(Gst.Format.TIME)[1]
self.player.seek(self.speed, Gst.Format.TIME, Gst.SeekFlags.FLUSH,
Gst.SeekType.SET, pos, Gst.SeekType.NONE, -1)
self.status = Status.PLAYING
self.emit('started', self.get_position())
示例6: get_position
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def get_position(self):
if self.player is not None:
self.player.get_state(Gst.CLOCK_TIME_NONE)
nanosecs = self.player.query_position(Gst.Format.TIME)[1]
position = float(nanosecs) / Gst.SECOND
return position
return 0
示例7: get_duration
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def get_duration(self):
if self.player is not None:
self.player.get_state(Gst.CLOCK_TIME_NONE)
duration_nanosecs = self.player.query_duration(Gst.Format.TIME)[1]
duration = float(duration_nanosecs) / Gst.SECOND
return duration
return 0
示例8: nsToPixel
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def nsToPixel(cls, duration):
"""Returns the pixel equivalent of the specified duration"""
# Here, a long time ago (206f3a05), a pissed programmer said:
# DIE YOU CUNTMUNCH CLOCK_TIME_NONE UBER STUPIDITY OF CRACK BINDINGS !!
if duration == Gst.CLOCK_TIME_NONE:
return 0
return int((float(duration) / Gst.SECOND) * cls.zoomratio)
示例9: nsToPixelAccurate
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def nsToPixelAccurate(cls, duration):
"""Returns the pixel equivalent of the specified duration."""
# Here, a long time ago (206f3a05), a pissed programmer said:
# DIE YOU CUNTMUNCH CLOCK_TIME_NONE UBER STUPIDITY OF CRACK BINDINGS !!
if duration == Gst.CLOCK_TIME_NONE:
return 0
return ((float(duration) / Gst.SECOND) * cls.zoomratio)
示例10: play
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def play(self):
'''
Play the player
'''
if self.player is not None:
self.player.set_state(Gst.State.PLAYING)
self.player.get_state(Gst.CLOCK_TIME_NONE)
self.player.get_by_name('removesilence').set_property(
'remove', self.removesilence)
self.player.get_by_name('volume').set_property('volume',
self.volume)
self.player.get_by_name('equalizer').set_property(
'band0', self.equalizer['band0'])
self.player.get_by_name('equalizer').set_property(
'band1', self.equalizer['band1'])
self.player.get_by_name('equalizer').set_property(
'band2', self.equalizer['band2'])
self.player.get_by_name('equalizer').set_property(
'band3', self.equalizer['band3'])
self.player.get_by_name('equalizer').set_property(
'band4', self.equalizer['band4'])
self.player.get_by_name('equalizer').set_property(
'band5', self.equalizer['band5'])
self.player.get_by_name('equalizer').set_property(
'band6', self.equalizer['band6'])
self.player.get_by_name('equalizer').set_property(
'band7', self.equalizer['band7'])
self.player.get_by_name('equalizer').set_property(
'band8', self.equalizer['band8'])
self.player.get_by_name('equalizer').set_property(
'band9', self.equalizer['band9'])
pos = self.player.query_position(Gst.Format.TIME)[1]
self.player.seek(self.speed, Gst.Format.TIME, Gst.SeekFlags.FLUSH,
Gst.SeekType.SET, pos, Gst.SeekType.NONE, -1)
self.status = Status.PLAYING
self.emit('started', self.get_position())
示例11: waitToReachState
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def waitToReachState(element, state, timeout= 3.0, attempts= 1):
import logging
while attempts:
stateReturn, currentState, pending = element.get_state( (timeout * Gst.SECOND) if timeout != Gst.CLOCK_TIME_NONE else Gst.CLOCK_TIME_NONE)
if currentState == state and ( stateReturn == Gst.StateChangeReturn.SUCCESS or stateReturn == Gst.StateChangeReturn.NO_PREROLL ):
return True
attempts -= 1
if attempts:
time.sleep(0.1)
return False
示例12: _playsoundNix
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def _playsoundNix(sound, block=True):
"""Play a sound using GStreamer.
Inspired by this:
https://gstreamer.freedesktop.org/documentation/tutorials/playback/playbin-usage.html
"""
if not block:
raise NotImplementedError(
"block=False cannot be used on this platform yet")
# pathname2url escapes non-URL-safe characters
import os
try:
from urllib.request import pathname2url
except ImportError:
# python 2
from urllib import pathname2url
import gi
gi.require_version('Gst', '1.0')
from gi.repository import Gst
Gst.init(None)
playbin = Gst.ElementFactory.make('playbin', 'playbin')
if sound.startswith(('http://', 'https://')):
playbin.props.uri = sound
else:
playbin.props.uri = 'file://' + pathname2url(os.path.abspath(sound))
set_result = playbin.set_state(Gst.State.PLAYING)
if set_result != Gst.StateChangeReturn.ASYNC:
raise PlaysoundException(
"playbin.set_state returned " + repr(set_result))
# FIXME: use some other bus method than poll() with block=False
# https://lazka.github.io/pgi-docs/#Gst-1.0/classes/Bus.html
bus = playbin.get_bus()
bus.poll(Gst.MessageType.EOS, Gst.CLOCK_TIME_NONE)
playbin.set_state(Gst.State.NULL)
示例13: save
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import CLOCK_TIME_NONE [as 别名]
def save(self, path):
"""Save the output of the TSM procedure to path, then quit the GObject
loop."""
self.sink.set_property('location', path)
self.set_state(Gst.State.PAUSED)
self.get_state(Gst.CLOCK_TIME_NONE)
self.playbin.seek(self._speed, Gst.Format.BYTES, Gst.SeekFlags.FLUSH,
Gst.SeekType.SET, 0, Gst.SeekType.NONE, -1)
self.set_state(Gst.State.PLAYING)