从 MPG 加载纹理
Loading texture from MPG
错误:
[ERROR ] [Image ] Error loading texture somevideo.mpg
实际结果:
- 出现错误,我无法使用除
play()
之外的任何属性
参考代码:
from functools import partial
from kivy.clock import Clock
from kivy.uix.video import Video
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.app import App
class VideoPlayScreen(Screen):
def __init__(self, **kwargs):
super(VideoPlayScreen, self).__init__(**kwargs)
box_layout = BoxLayout()
self.video1 = Video(source="cityCC0.mpg")
box_layout.add_widget(self.video1)
self.add_widget(box_layout)
def on_enter(self, *args):
print(self.video1.state)
self.video1.state = "play"
print(self.video1.state)
Clock.schedule_interval(partial(print, self.video1.loaded), 0.5)
sm = ScreenManager()
sm.add_widget(VideoPlayScreen(name="video_play"))
sm.current = "video_play"
class OpenCity(App):
def build(self):
return sm
if __name__ == '__main__':
OpenCity().run()
cityCC1.mpg是kivy给的。在 kivy_examples 文件夹中检查它。
运行日志:
[INFO ] [Logger ] Record log in C:\Users\kanna\.kivy\logs\kivy_20-03-01_28.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.1.23
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "F:\Python Kivy\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.7.6 (tags/v3.7.6:43364a7ae0, Dec 18 2019, 23:46:00) [MSC v.1916 32 bit (Intel)]
[INFO ] [Python ] Interpreter at "F:\Python Kivy\Scripts\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [ImageLoaderFFPy] Using ffpyplayer 4.3.0
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_ffpyplayer, img_gif (img_pil ignored)
[INFO ] [VideoGstplayer] Using Gstreamer 1.16.2.0
[INFO ] [Video ] Provider: gstplayer
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 - Build 26.20.100.7262'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) UHD Graphics 630'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 - Build 26.20.100.7262'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[ERROR ] [Image ] Error loading texture cityCC0.mpg
[INFO ] [Base ] Start application main loop
stop
play
False 0.9090554999999999
[INFO ] [GL ] NPOT texture support is available
False 0.5063968000000001
False 0.4993861999999998
False 0.49537330000000024
[INFO ] [WindowSDL ] exiting mainloop and closing.
[INFO ] [Base ] Leaving application in progress...
它将 运行 日志显示为代码。
一如既往地感谢阅读。
此后的问题将 link 发送到包含代码日志的 pastebin。
根据 documentation、partial
“freezes” some portion of a function’s arguments
因此 partial
中的 print
函数只是打印 self.video1.loaded
的值,就像调用 partial
函数时一样。
这是您发布的代码的一个版本,它每半秒打印一次 loaded
的当前版本:
from kivy.clock import Clock
from kivy.uix.video import Video
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.app import App
class VideoPlayScreen(Screen):
def __init__(self, **kwargs):
super(VideoPlayScreen, self).__init__(**kwargs)
box_layout = BoxLayout()
self.video1 = Video(source="cityCC0.mpg")
box_layout.add_widget(self.video1)
self.add_widget(box_layout)
def on_enter(self, *args):
print(self.video1.state)
self.video1.state = "play"
print(self.video1.state)
Clock.schedule_interval(self.check_loaded, 0.5)
def check_loaded(self, dt):
print(self.video1.loaded)
sm = ScreenManager()
sm.add_widget(VideoPlayScreen(name="video_play"))
sm.current = "video_play"
class OpenCity(App):
def build(self):
return sm
if __name__ == '__main__':
OpenCity().run()
结果输出:
[ERROR ] [Image ] Error loading texture cityCC0.mpg
stop
play
[INFO ] [ProbeSysfs ] device match: /dev/input/event7
[INFO ] [MTD ] Read event from </dev/input/event7>
[INFO ] [ProbeSysfs ] device match: /dev/input/event4
[INFO ] [MTD ] Read event from </dev/input/event4>
[INFO ] [Base ] Start application main loop
[WARNING] [MTD ] Unable to open device "/dev/input/event7". Please ensure you have the appropriate permissions.
[WARNING] [MTD ] Unable to open device "/dev/input/event4". Please ensure you have the appropriate permissions.
False
[INFO ] [GL ] NPOT texture support is available
True
True
True
True
错误:
[ERROR ] [Image ] Error loading texture somevideo.mpg
实际结果:
- 出现错误,我无法使用除
play()
之外的任何属性
参考代码:
from functools import partial
from kivy.clock import Clock
from kivy.uix.video import Video
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.app import App
class VideoPlayScreen(Screen):
def __init__(self, **kwargs):
super(VideoPlayScreen, self).__init__(**kwargs)
box_layout = BoxLayout()
self.video1 = Video(source="cityCC0.mpg")
box_layout.add_widget(self.video1)
self.add_widget(box_layout)
def on_enter(self, *args):
print(self.video1.state)
self.video1.state = "play"
print(self.video1.state)
Clock.schedule_interval(partial(print, self.video1.loaded), 0.5)
sm = ScreenManager()
sm.add_widget(VideoPlayScreen(name="video_play"))
sm.current = "video_play"
class OpenCity(App):
def build(self):
return sm
if __name__ == '__main__':
OpenCity().run()
cityCC1.mpg是kivy给的。在 kivy_examples 文件夹中检查它。
运行日志:
[INFO ] [Logger ] Record log in C:\Users\kanna\.kivy\logs\kivy_20-03-01_28.txt
[INFO ] [deps ] Successfully imported "kivy_deps.gstreamer" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.glew" 0.2.0
[INFO ] [deps ] Successfully imported "kivy_deps.sdl2" 0.1.23
[INFO ] [Kivy ] v1.11.1
[INFO ] [Kivy ] Installed at "F:\Python Kivy\lib\site-packages\kivy\__init__.py"
[INFO ] [Python ] v3.7.6 (tags/v3.7.6:43364a7ae0, Dec 18 2019, 23:46:00) [MSC v.1916 32 bit (Intel)]
[INFO ] [Python ] Interpreter at "F:\Python Kivy\Scripts\python.exe"
[INFO ] [Factory ] 184 symbols loaded
[INFO ] [ImageLoaderFFPy] Using ffpyplayer 4.3.0
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_ffpyplayer, img_gif (img_pil ignored)
[INFO ] [VideoGstplayer] Using Gstreamer 1.16.2.0
[INFO ] [Video ] Provider: gstplayer
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 - Build 26.20.100.7262'>
[INFO ] [GL ] OpenGL vendor <b'Intel'>
[INFO ] [GL ] OpenGL renderer <b'Intel(R) UHD Graphics 630'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 - Build 26.20.100.7262'>
[INFO ] [GL ] Texture max size <16384>
[INFO ] [GL ] Texture max units <32>
[INFO ] [Window ] auto add sdl2 input provider
[INFO ] [Window ] virtual keyboard not allowed, single mode, not docked
[ERROR ] [Image ] Error loading texture cityCC0.mpg
[INFO ] [Base ] Start application main loop
stop
play
False 0.9090554999999999
[INFO ] [GL ] NPOT texture support is available
False 0.5063968000000001
False 0.4993861999999998
False 0.49537330000000024
[INFO ] [WindowSDL ] exiting mainloop and closing.
[INFO ] [Base ] Leaving application in progress...
它将 运行 日志显示为代码。
一如既往地感谢阅读。
此后的问题将 link 发送到包含代码日志的 pastebin。
根据 documentation、partial
“freezes” some portion of a function’s arguments
因此 partial
中的 print
函数只是打印 self.video1.loaded
的值,就像调用 partial
函数时一样。
这是您发布的代码的一个版本,它每半秒打印一次 loaded
的当前版本:
from kivy.clock import Clock
from kivy.uix.video import Video
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.app import App
class VideoPlayScreen(Screen):
def __init__(self, **kwargs):
super(VideoPlayScreen, self).__init__(**kwargs)
box_layout = BoxLayout()
self.video1 = Video(source="cityCC0.mpg")
box_layout.add_widget(self.video1)
self.add_widget(box_layout)
def on_enter(self, *args):
print(self.video1.state)
self.video1.state = "play"
print(self.video1.state)
Clock.schedule_interval(self.check_loaded, 0.5)
def check_loaded(self, dt):
print(self.video1.loaded)
sm = ScreenManager()
sm.add_widget(VideoPlayScreen(name="video_play"))
sm.current = "video_play"
class OpenCity(App):
def build(self):
return sm
if __name__ == '__main__':
OpenCity().run()
结果输出:
[ERROR ] [Image ] Error loading texture cityCC0.mpg
stop
play
[INFO ] [ProbeSysfs ] device match: /dev/input/event7
[INFO ] [MTD ] Read event from </dev/input/event7>
[INFO ] [ProbeSysfs ] device match: /dev/input/event4
[INFO ] [MTD ] Read event from </dev/input/event4>
[INFO ] [Base ] Start application main loop
[WARNING] [MTD ] Unable to open device "/dev/input/event7". Please ensure you have the appropriate permissions.
[WARNING] [MTD ] Unable to open device "/dev/input/event4". Please ensure you have the appropriate permissions.
False
[INFO ] [GL ] NPOT texture support is available
True
True
True
True