mirror of https://github.com/kivy/kivy.git
Make VideoFFPy work with RTSP streams. (#8171)
* Make VideoFFPy work with RTSP streams. * Remove superfluous loop waiting for metadata from ffpyplayer. This already happens above when checking src_pix_fmt. * src_pix_fmt is reported as bytes from ffpyplayer * Remove preventing seek on streams, stream may or may not provide seeking. * Check src_pix_fmt for both bytes and str in VideoFFPy._next_frame_run. * Comment the purpose of VideoFFPy._is_stream
This commit is contained in:
parent
7f23e32441
commit
c4a52ed078
|
@ -55,6 +55,7 @@ kivy/deps/*
|
|||
kivy.deps*
|
||||
kivy/version.py
|
||||
results.png
|
||||
kivy-dependencies
|
||||
|
||||
MANIFEST
|
||||
|
||||
|
|
|
@ -115,6 +115,14 @@ class VideoFFPy(VideoBase):
|
|||
|
||||
super(VideoFFPy, self).__init__(**kwargs)
|
||||
|
||||
@property
|
||||
def _is_stream(self):
|
||||
# This is only used when building ff_opts, to prevent starting
|
||||
# player paused and can probably be removed as soon as the 'eof'
|
||||
# receiving issue is solved.
|
||||
# See https://github.com/matham/ffpyplayer/issues/142
|
||||
return self.filename.startswith('rtsp://')
|
||||
|
||||
def __del__(self):
|
||||
self.unload()
|
||||
|
||||
|
@ -211,7 +219,7 @@ class VideoFFPy(VideoBase):
|
|||
self._texture = fbo.texture
|
||||
else:
|
||||
self._texture = Texture.create(size=self._size,
|
||||
colorfmt='rgba')
|
||||
colorfmt='rgba')
|
||||
|
||||
# XXX FIXME
|
||||
# self.texture.add_reload_observer(self.reload_buffer)
|
||||
|
@ -250,7 +258,9 @@ class VideoFFPy(VideoBase):
|
|||
wait_for_wakeup(0.005)
|
||||
continue
|
||||
|
||||
if src_pix_fmt == 'yuv420p':
|
||||
# ffpyplayer reports src_pix_fmt as bytes. this may or may not
|
||||
# change in future, so we check for both bytes and str
|
||||
if src_pix_fmt in (b'yuv420p', 'yuv420p'):
|
||||
self._out_fmt = 'yuv420p'
|
||||
ffplayer.set_output_pix_fmt(self._out_fmt)
|
||||
break
|
||||
|
@ -259,17 +269,6 @@ class VideoFFPy(VideoBase):
|
|||
ffplayer.close_player()
|
||||
return
|
||||
|
||||
# wait until loaded or failed, shouldn't take long, but just to make
|
||||
# sure metadata is available.
|
||||
while not self._ffplayer_need_quit:
|
||||
if ffplayer.get_metadata()['src_vid_size'] != (0, 0):
|
||||
break
|
||||
wait_for_wakeup(0.005)
|
||||
|
||||
if self._ffplayer_need_quit:
|
||||
ffplayer.close_player()
|
||||
return
|
||||
|
||||
self._ffplayer = ffplayer
|
||||
self._finish_setup()
|
||||
# now, we'll be in internal paused state and loop will wait until
|
||||
|
@ -389,9 +388,13 @@ class VideoFFPy(VideoBase):
|
|||
# load first unloads
|
||||
self.load()
|
||||
self._out_fmt = 'rgba'
|
||||
# it starts internally paused, but unpauses itself
|
||||
# if no stream, it starts internally paused, but unpauses itself
|
||||
# if stream and we start paused, we sometimes receive eof after a
|
||||
# few frames, depending on the stream producer.
|
||||
# XXX: This probably needs to be figured out in ffpyplayer, using
|
||||
# ffplay directly works.
|
||||
ff_opts = {
|
||||
'paused': True,
|
||||
'paused': not self._is_stream,
|
||||
'out_fmt': self._out_fmt,
|
||||
'sn': True,
|
||||
'volume': self._volume,
|
||||
|
|
Loading…
Reference in New Issue