本文整理汇总了Python中gi.repository.Gst.SECOND属性的典型用法代码示例。如果您正苦于以下问题:Python Gst.SECOND属性的具体用法?Python Gst.SECOND怎么用?Python Gst.SECOND使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gi.repository.Gst
的用法示例。
在下文中一共展示了Gst.SECOND属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_slider_seek
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def on_slider_seek(self, widget):
if self.uri.endswith(".JPG"):
seek_intvl = ply.slider.get_value()
files = len(os.listdir("Images_100"))
seek_file = int((files * seek_intvl) / 100)
self.clear_playbin()
self.setup_player(os.path.join("Images_100",
sorted(os.listdir("Images_100"))[seek_file]),
)
self.pause()
elif not self.uri.endswith(".png"):
seek_time = ply.slider.get_value()
self.player.seek_simple(Gst.Format.TIME,
Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
seek_time * Gst.SECOND / self.mult,
)
示例2: set_position
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [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)
示例3: _create_intersrc
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _create_intersrc(self, audio_or_video):
'''
Create the intervideosrc / interaudiosrc
'''
assert(audio_or_video in ['audio', 'video'])
# Create the receiving 'inter' element to accept the AV into the main pipeline
self._intersrc_element[audio_or_video] =\
self._add_element_to_dest_pipeline('inter%ssrc' % audio_or_video, audio_or_video)
# We ask the src to hold the frame for 24 hours (basically, a very long time)
# This is optional, but prevents it from going black when it's better to show the last frame.
if audio_or_video is 'video':
self._intersrc_element[audio_or_video].set_property('timeout', Gst.SECOND * 60 * 60 * 24)
return self._intersrc_element[audio_or_video]
示例4: __init__
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [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)
示例5: _notify_caps
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _notify_caps(self, pad, *args):
"""notify::caps callback"""
self._caps = True
info = pad.get_current_caps().get_structure(0)
self._duration = pad.get_peer().query_duration(Gst.Format.TIME).duration / Gst.SECOND
channels = info.get_int('channels')[1]
sample_rate = info.get_int('rate')[1]
sample_size = int("".join(filter(str.isdigit, info.get_string('format'))))
self.audio_format = AudioFormat(channels=channels,
sample_size=sample_size,
sample_rate=sample_rate)
# Allow __init__ to complete:
self._is_ready.set()
示例6: get_audio_data
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def get_audio_data(self, num_bytes, compensation_time=0.0):
if self._finished.is_set():
return None
data = bytes()
while len(data) < num_bytes:
packet = self._queue.get()
if packet == self._sentinal:
self._finished.set()
break
data += packet
if not data:
return None
timestamp = self._pipeline.query_position(Gst.Format.TIME).cur / Gst.SECOND
duration = self.audio_format.bytes_per_second / len(data)
return AudioData(data, len(data), timestamp, duration, [])
示例7: _get_length
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _get_length(self):
if self._data is not None:
if self._data.get_state()[1] != Gst.State.PLAYING:
volume_before = self._data.get_property('volume')
self._data.set_property('volume', 0)
self._data.set_state(Gst.State.PLAYING)
try:
self._data.get_state()
ret, value = self._data.query_duration(Gst.Format.TIME)
if ret:
return value / float(Gst.SECOND)
finally:
self._data.set_state(Gst.State.NULL)
self._data.set_property('volume', volume_before)
else:
ret, value = self._data.query_duration(Gst.Format.TIME)
if ret:
return value / float(Gst.SECOND)
return super(SoundGi, self)._get_length()
示例8: update_slider
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def update_slider(self):
if not self.is_playing:
return False # cancel timeout
else:
success, self.duration = self.playbin.query_duration(Gst.Format.TIME)
if not success:
raise GenericException("Couldn't fetch song duration")
else:
self.slider.set_range(0, self.duration / Gst.SECOND)
#fetching the position, in nanosecs
success, position = self.playbin.query_position(Gst.Format.TIME)
if not success:
raise GenericException("Couldn't fetch current song position to update slider")
# block seek handler so we don't seek when we set_value()
self.slider.handler_block(self.slider_handler_id)
self.slider.set_value(float(position) / Gst.SECOND)
self.slider.handler_unblock(self.slider_handler_id)
return True # continue calling every x milliseconds
示例9: skip_minute
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def skip_minute(self, direction=1):
self.player.seek_simple(Gst.Format.TIME,
Gst.SeekFlags.FLUSH | Gst.SeekFlags.KEY_UNIT,
self.current_position() + float(60) * Gst.SECOND * direction,
)
示例10: update_slider
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def update_slider(self):
if not self.is_playing:
return False # cancel timeout
else:
success, self.duration = self.player.query_duration(Gst.Format.TIME)
# adjust duration and position relative to absolute scale of 100
try:
self.mult = 100 / (self.duration / Gst.SECOND)
except ZeroDivisionError:
cli.log.exception(_("Exception error"))
if not success:
# raise SliderUpdateException("Couldn"t fetch duration")
cli.log.warning(_("Couldn't fetch duration"))
# fetching the position, in nanosecs
success, position = self.player.query_position(Gst.Format.TIME)
if not success:
# raise SliderUpdateException("Couldn"t fetch current position to update slider")
cli.log.warning(_("Couldn't fetch current position to update slider"))
# block seek handler so we don"t seek when we set_value()
self.slider.handler_block(self.slider_handler_id)
self.slider.set_value(float(position) / Gst.SECOND * self.mult)
self.slider.handler_unblock(self.slider_handler_id)
return True # continue calling every x milliseconds
示例11: get_position
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [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
示例12: get_duration
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [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
示例13: _video_pipeline_start
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def _video_pipeline_start(self):
'''
The standard start to the pipeline string for video.
It starts with intervideosrc, which accepts video from the source.
'''
# The large timeout holds any stuck frame for 24 hours (basically, a very long time)
# This is optional, but prevents it from going black when it's better to show the last frame.
timeout = Gst.SECOND * 60 * 60 * 24
return ('intervideosrc name=intervideosrc timeout=%d ! videoconvert ! videoscale ! '
'videorate ! capsfilter name=capsfilter ! ' % timeout)
示例14: pixelToNs
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def pixelToNs(cls, pixel):
"""Returns the duration equivalent of the specified pixel."""
return int(pixel * Gst.SECOND / cls.zoomratio)
示例15: pixelToNsAt
# 需要导入模块: from gi.repository import Gst [as 别名]
# 或者: from gi.repository.Gst import SECOND [as 别名]
def pixelToNsAt(cls, pixel, ratio):
"""Returns the duration equivalent of the specified pixel."""
return int(pixel * Gst.SECOND / ratio)