Kivy Video Player无法在Raspberry 3B +上运行 [英] Kivy Video Player is not working on Raspberry 3B+

查看:139
本文介绍了Kivy Video Player无法在Raspberry 3B +上运行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚在RPI3+上安装了Rasbian Stretch和Kivy.我的应用程序正常工作,只是视频没有播放. rasbian,kivy和gstreamer都是最新的.我的应用程序和视频可以在KivyPie 0.9b上正常运行.

I just installed Rasbian Stretch and Kivy on my RPI3+. My application work properly just videos are not playing. Rasbian, kivy and gstreamer are up to date. My application and video were working on KivyPie 0.9b without any problem.

kivy是否有用于手动安装Rasbian的视频播放配置?

Does kivy has any config for video playing on manual installation of Rasbian?

输出日志:

[INFO] [MTD]旋转设置为0
[警告] [图像]无法加载图像
[错误] [图像]加载纹理./data/images/welcome.mp4
[错误] [VideoGstplayer] GStreamer遇到一般的支持库错误.
[错误] [VideoGstplayer] GStreamer遇到一般的支持库错误.
[ERROR] [VideoGstplayer]内部数据流错误.

[INFO ] [MTD ] rotation set to 0
[WARNING] [Image ] Unable to load image
[ERROR ] [Image ] Error loading texture ./data/images/welcome.mp4
[ERROR ] [VideoGstplayer] GStreamer encountered a general supporting library error.
[ERROR ] [VideoGstplayer] GStreamer encountered a general supporting library error.
[ERROR ] [VideoGstplayer] Internal data stream error.

推荐答案

我尝试了很长时间,因此感到很自在,无法在树莓派上使用标准的kivy视频播放器.

I tried a long time and therefore feel comfortable saying, there is no way to use the standard kivy videoplayer on a raspberry pi.

替代方法是使用OMXPlayer.我为OMXPlayer使用了以下包装 https://github.com/willprice/python-omxplayer-wrapper 也许首先尝试使Raspberry Pi上的OMXPlayer正常工作.

The alternative is to use OMXPlayer. I used the following wrapper for OMXPlayer https://github.com/willprice/python-omxplayer-wrapper maybe try first to get OMXPlayer on the Raspberry Pi working.

这是我写的一个旧脚本,用于在树莓派上使用kivy gui时观看视频

That's an old script I wrote to view a video while using a kivy gui on raspberry pi

我希望它能对您有所帮助,您可以将其视为寻找自己的解决方案的灵感

I hope it helps and you can see it as an inspiration for finding your own solution

主要逻辑是将OMXPlayer放在后台,并使猕猴桃透明.看到clearbckgrnd

Main logic is to put OMXPlayer in the background and make kivy see-through. see 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')

这篇关于Kivy Video Player无法在Raspberry 3B +上运行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆