Rud*_*ini 0 python windows tkinter vlc
我正在尝试通过 VLC 在 python Tkinter 中重现带声音的视频,但无法运行该文件,因为在运行 import vlc 行时出现错误。
\n\n我有 32 位的 python 3、32 位的 VLC 播放器并通过安装pip install python-VLC,这是成功的,然后尝试运行代码并收到此错误:
File "C:/Users/momoh/Documents/GitHub/CNDH/CNDH.py", line 5, in <module>\n import vlc\n File "C:\\Users\\momoh\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\vlc.py", line 207, in <module>\n dll, plugin_path = find_lib()\n File "C:\\Users\\momoh\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\site-packages\\vlc.py", line 163, in find_lib\n dll = ctypes.CDLL(libname)\n File "C:\\Users\\momoh\\AppData\\Local\\Programs\\Python\\Python36-32\\lib\\ctypes\\__init__.py", line 348, in __init__\n self._handle = _dlopen(self._name, mode)\nOSError: [WinError 126] The specified module could not be found \nRun Code Online (Sandbox Code Playgroud)\n\n这是我\xc2\xb4m 尝试运行的代码:\n我的导入:
\n\nimport sys\nimport tkinter as tk \nfrom tkinter import font as tkfont \nfrom PIL import ImageTk, Image\nimport vlc\nRun Code Online (Sandbox Code Playgroud)\n\n以及包含视频的帧的类
\n\nclass PageThree(tk.Frame):\n\n def __init__(self, parent, controller):\n tk.Frame.__init__(self, parent)\n self.controller = controller\n self.grid_columnconfigure(0, weight=0)\n self.grid_columnconfigure(1, weight=1)\n self.grid_columnconfigure(2, weight=2)\n self.grid_columnconfigure(3, weight=1)\n self.grid_columnconfigure(4, weight=0)\n self.grid_rowconfigure(0, weight=0)\n self.grid_rowconfigure(1, weight=1)\n self.grid_rowconfigure(2, weight=2)\n self.grid_rowconfigure(3, weight=3)\n self.grid_rowconfigure(4, weight=2)\n self.grid_rowconfigure(5, weight=1)\n self.grid_rowconfigure(6, weight=6)\n\n self.configure(background="white")\n\n\n # Open the video source |temporary\n self.video_source = "assetsCNDH/prueba.mp4"\n\n # Canvas where to draw video output\n self.canvas = tk.Canvas(self, width= controller.winfo_screenwidth(),\n height=controller.winfo_screenheight(), bg="black",\n highlightthickness=0)\n self.canvas.pack()\n\n # Creating VLC player\n self.instance = vlc.Instance()\n self.player = self.instance.media_player_new()\n\n def GetHandle(self):\n # Getting frame ID\n return self.winfo_id()\n\n def play(self, _source):\n # Function to start player from given source\n Media = self.instance.media_new(_source)\n Media.get_mrl()\n self.player.set_media(Media)\n\n # self.player.play()\n self.player.set_hwnd(self.GetHandle())\n self.player.play()\nRun Code Online (Sandbox Code Playgroud)\n\n如何让我的视频运行?
\nPython-vlc is a binding of python to vlc program (or wrapper libraries). It is a way to run vlc program via python (python -> binding -> vlc). It will not run the vlc program itself so you need to do the following steps:
1) download vlc program and install it in your machine
2) restart your machine
3) run notebook again
Run Code Online (Sandbox Code Playgroud)
You may download and install vlc (64-bit) in this link: https://www.videolan.org/vlc/
Reference:
https://wiki.videolan.org/PythonBinding
Run Code Online (Sandbox Code Playgroud)
quote:
Note that this only installs the python module itself, which depends on the availability of the libvlc libraries. You must also install VLC itself to get these libraries.