簡體   English   中英

我如何判斷 wx.media.MediaCtrl 是否包含在我的 wxPython 安裝中?

[英]How can I tell if wx.media.MediaCtrl was included in my installation of wxPython?

問題是什么:我正在嘗試讓 wxPython,特別是 wx.media.MediaCtrl,在我運行 Raspbian bullseye 的 Raspberry Pi 上工作。 我試圖在按下按鈕時播放 mp4 視頻,但我不斷收到這樣的錯誤:

Traceback (most recent call last):
  File "/home/[User Name]/Downloads/testapp/testapp.py", line 152, in lesson_one_frame
    frame = videoFrame(title=title)
  File "/home/[User Name]/Downloads/testapp/testapp.py", line 87, in __init__
    self.testMedia = wx.media.MediaCtrl(self, style=wx.SIMPLE_BORDER, szBackend=wx.media.MEDIABACKEND_GSTREAMER)
NotImplementedError

以下是有關我正在運行的版本的更多信息:

  • wxPython:4.2.0
  • GStreamer 核心庫:1.18.4
  • Python:3.9.2
  • pip:22.3.1

我試過什么:在谷歌搜索最初的問題后,我發現了這個 StackOverFlow 問題Getting a "NotImplementedError" in wxPython其中最重要的答案是這樣的:

wxMediaCtrl 是構建的可選部分,如果 wxWidgets 的配置腳本無法找到正確的依賴庫或它們的 -devel 包未安裝,它將自動被排除。 當使用不帶 wxMediaCtrl 的 wxWigets 構建 wxPython 時,它會創建一個存根 class,如果您嘗試使用它,它只會引發 NotImplementedError。

我不確定我的問題是否是 wx.media.MediaCtrl 不是構建的一部分或 Gstreamer 不工作的問題,所以我測試了 GStreamer。 我輸入了這個gst-launch-1.0 videotextsrc ! videoconvert ! autovideosink gst-launch-1.0 videotextsrc ! videoconvert ! autovideosink gst-launch-1.0 videotextsrc ! videoconvert ! autovideosink進入終端,它可以顯示測試視頻。

在測試 GStreamer 之后,我開始尋找方法來判斷 wxMediaCtrl 是否是構建的一部分,我發現這個 StackOverFlow 問題wxMediaCtrl 在安裝過程中被排除在外,答案表明可能缺少一些庫依賴項,並嘗試此處列出的步驟https://wxpython .org/blog/2017-08-17-builds-for-linux-with-pip/ 我已經執行了所有這些步驟,但它仍然給我NotImplementedError

代碼示例:

這是我使用 wxMediaCtrl 的代碼示例


import wx, wx.media
import wx.html


class videoFrame(wx.Frame):
    def __init__(self, title, parent=None):
        wx.Frame.__init__(self, parent=parent, title=title)
        
        # This line is where the problem is.
        self.testMedia = wx.media.MediaCtrl(self, style=wx.SIMPLE_BORDER, szBackend=wx.media.MEDIABACKEND_GSTREAMER)
        self.media = 'testVideo.mp4'

        self.testMedia.Bind(wx.media.EVT_MEDIA_LOADED, self.play)
        self.testMedia.Bind(wx.media.EVT_MEDIA_FINISHED, self.quit)
        if self.testMedia.Load(self.media):
            pass
        else:
            print("Media not found")
            self.quit(None)
    
    def play(self, event):
        self.testMedia.Play()

    def quit(self, event):
        self.Destroy()


class mainAppFrame(wx.Frame):
    def __init__(self, title, parent=None):
        wx.Frame.__init__(self, parent=parent, title=title)
        panel = wx.Panel(self)

        lessonOneBtn = wx.Button(panel, label="Lesson 1")
        self.Bind(wx.EVT_BUTTON, self.OnLessonOnePress, lessonOneBtn)
        

    def OnLessonOnePress(self, event):
        title = 'Lesson One'
        frame = videoFrame(title=title)


編輯**:發布后我檢查了我的 build.log 文件,看看我是否遺漏了什么,我發現了這個:

checking for GST... configure: GStreamer 1.7.2+ not available. Not using GstPlayer and falling back to 1.0
checking for GST... configure: WARNING: GStreamer 1.0 not available, falling back to 0.10
checking for GST... configure: WARNING: GStreamer 0.10 not available
configure: WARNING: GStreamer not available... disabling wxMediaCtrl

因此,當我出於某種原因安裝 wxPython 時,它似乎找不到 GStreamer。 我相信 GStreamer 已正確安裝,因為命令gst-launch-1.0 videotextsrc ! videoconvert ! autovideosink gst-launch-1.0 videotextsrc ! videoconvert ! autovideosink gst-launch-1.0 videotextsrc ! videoconvert ! autovideosink工作。

以下是我下載的與 GStreamer 相關的包:

  • libgstreamer1.0-dev
  • libgstreamer-plugins-base1.0-dev
  • libgstreamer-plugins-bad1.0-dev
  • libgstreamer1.0-0
  • gstreamer1.0-plugins-base
  • gstreamer1.0-plugins-good
  • gstreamer1.0-plugins-壞
  • gstreamer1.0-plugins-丑陋
  • gstreamer1.0-libav
  • gstreamer1.0-文檔
  • gstreamer1.0-工具
  • gstreamer1.0-x
  • gstreamer1.0-alsa
  • gstreamer1.0-gl
  • gstreamer1.0-gtk3

所有這些似乎都位於 /usr/lib/arm-linux-gnueabihf/ 中。 我還嘗試使用pkg-config pkg-config --cflags --libs gstreamer-1.0將它們添加到我的 pkg-config 中,就像它在此處所說的那樣https://gstreamer.freedesktop.org/documentation/installing/on -linux.html?gi-language=c但我收到錯誤:

Package gstreamer-1.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing 'gstreamer-1.0.pc'
to the PKG_CONFIG_PATH environment variable
No package 'gstreamer-1.0' found

然后我嘗試使用locate gstreamer | grep pc locate gstreamer | grep pc ,即使安裝了 GStreamer,也沒有 .pc 文件。 如果我能找到更多信息,我會更新。

libstreamer1.0-dev package應該包含gstreamer-1.0.pc文件,所以你說你沒有它真的很奇怪,即使你已經安裝了package。

如果您確實有該文件,您可以嘗試將PKG_CONFIG_LIBDIR設置為明確包含它的目錄以幫助配置找到它,但通常它不是必需的。 請檢查您的config.log ,也許您可以在那里找到找不到它的原因。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM