我刚刚在RPI3+
上安装了Rasbian Stretch和Kivy。我的应用程序正常工作,只是视频没有播放。 rasbian,kivy和gstreamer是最新的。我的应用程序和视频可以在KivyPie 0.9b
上正常运行。
kivy
是否有用于手动安装Rasbian的视频播放配置?
输出日志:
[INFO] [MTD]旋转设置为0
[警告] [图像]无法加载图像
[错误] [图像]加载纹理./data/images/welcome.mp4
[错误] [VideoGstplayer] GStreamer遇到一般的支持库错误。
[错误] [VideoGstplayer] GStreamer遇到一般的支持库错误。
[ERROR] [VideoGstplayer]内部数据流错误。
答案 0 :(得分:0)
我尝试了很长时间,因此感到很自在,无法在树莓派上使用标准的kivy视频播放器。
替代方法是使用OMXPlayer。我为OMXPlayer使用了以下包装 https://github.com/willprice/python-omxplayer-wrapper 也许首先尝试使Raspberry Pi上的OMXPlayer正常工作。
这是我写的旧脚本,用于在树莓派上使用kivy gui时观看视频
我希望它能对您有所帮助,您可以将其视为寻找自己的解决方案的灵感
主要逻辑是将OMXPlayer放在后台,并使猕猴桃透明。参见clearbckgrnd
import subprocess
import os
from time import sleep
# https://github.com/willprice/python-omxplayer-wrapper
from omxplayer.player import OMXPlayer
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.screenmanager import Screen
from kivy.lang import Builder
from kivy.properties import ObjectProperty, BooleanProperty
from kivy.core.window import Window
from kivy.clock import Clock
class VideoPlayerScreen(Screen):
slider = ObjectProperty()
minimized = BooleanProperty(False)
@staticmethod
def clearbckgrnd():
Window.clearcolor = (0,0,0,0)
@staticmethod
def addbckgrnd():
Window.clearcolor = (0,0,0,1)
def play(self):
self.player = OMXPlayer('/home/pi/voice-recognizer-raspi/GUI/test.mp4')
self.player.set_video_pos(0,0,800,480)
#self.player.hide_video()
#self.player.show_video()
self.set_slider()
Clock.schedule_once(self.quit, 20)
Clock.schedule_interval(self.set_slider, 3)
def playpause(self):
self.player.play_pause()
def quit(self, gg, **kwargs):
self.player.quit()
App.get_running_app().stop()
def set_slider(self, *args):
pos = self.player.position() # in seconds as int
duration = self.player.duration() # in seconds as float
#return pos/duration
self.slider.value_normalized = pos/duration
#return 0.5
def set_videopos(self, *args):
pos = self.player.position() # in seconds as int
duration = self.player.duration() # in seconds as float
if abs (pos/duration - self.slider.value_normalized) > 0.05:
self.player.set_position(self.slider.value_normalized*duration)
def change_size(self):
#width 800
#height 480
if not self.minimized:
self.player.set_video_pos(2,2,798,418)
class VideoApp(App):
def build(self):
return Builder.load_string('''
ScreenManager:
Screen:
Button:
on_press: root.current = "video"
on_press: self.enabled= False
VideoPlayerScreen:
<VideoPlayerScreen>:
slider: slider
name: "video"
on_enter: self.clearbckgrnd()
on_enter: self.play()
on_pre_leave: self.addbckgrnd()
BoxLayout:
orientation: 'vertical'
Button:
size_hint_y: 420
#text: "play"
on_press: print('button to minimize pressed')
on_press: root.change_size()
background_color: (0,0,0,1)
Image:
source: './Infinity.gif'
height: self.parent.height / 1.5
y: self.parent.y + self.parent.height /2 - self.height / 2
x: self.parent.x + self.parent.width / 2 - self.width / 2
allow_stretch: False
BoxLayout:
orientation: 'vertical'
size_hint_y: 60
Slider:
id: slider
on_value: root.set_videopos(self.value_normalized)
#value_normalized: root.set_slider
BoxLayout:
Button:
text: 'Play/Pause'
on_press: root.playpause()
''')
if __name__ == "__main__":
video = VideoApp()
try:
video.run()
except KeyboardInterrupt:
video.stop()
os.system('killall dbus-daemon')