Python Gstreamer 1.0冻结到一个独立的应用程序中-可能吗?

Python Gstreamer 1.0冻结到一个独立的应用程序中-可能吗?,python,gstreamer,gtk3,cx-freeze,Python,Gstreamer,Gtk3,Cx Freeze,我一直在努力让Python GStreamer 1.0绑定在它自己的可执行文件中独立运行。事实证明,它比我预想的要复杂得多,而且几乎没有相关的文档。因此,我将详细介绍对我有效的方法,希望人们能够在这种方法上添加可以改进的内容 我第一次尝试用PyInstaller编译它,希望我能把它简化为一个exe文件,但是经过几天的努力,我发现GStreamer 1.0运行的GTK+3使用了命名空间包,目前只有cx_Freeze支持。(最终也使用PyInstaller 3.0) 这是一个大问题,但为了让它在一个

我一直在努力让Python GStreamer 1.0绑定在它自己的可执行文件中独立运行。事实证明,它比我预想的要复杂得多,而且几乎没有相关的文档。因此,我将详细介绍对我有效的方法,希望人们能够在这种方法上添加可以改进的内容

我第一次尝试用PyInstaller编译它,希望我能把它简化为一个exe文件,但是经过几天的努力,我发现GStreamer 1.0运行的GTK+3使用了命名空间包,目前只有cx_Freeze支持。(最终也使用PyInstaller 3.0)

这是一个大问题,但为了让它在一个独立的程序中工作,还需要进行其他修改

运行:

  • gstreamer-1.0-devel-x86-1.2.3

  • pygi-aio-3.10.2-win32_rev16(在安装程序中指定时创建gnome文件夹并添加gstreamer dll)

下面是我最后得到的一个cx_freeze安装文件,它使用“bdist_msi”标志运行:

################################
######### CX-FREEZE ############
################################
import os, site, sys
from cx_Freeze import setup, Executable

include_files = []
import site
include_dll_path = site.getsitepackages()[-1]

###### FINDING Gstreamer FILES TO BE INCLUDED ######
## Collect the list of missing dll when cx_freeze builds the app

gnomePath = os.path.join(include_dll_path, "gnome")
for fileName in os.listdir(gnomePath): 
    fullname = os.path.join(gnomePath, fileName) 
    if os.path.isfile(fullname): 
        include_files.append((fullname, fileName))

## We need to add all the libraries too (for themes, etc..)
gtk_libs = ['lib']
for lib in gtk_libs:
    include_files.append((os.path.join(include_dll_path, "gnome", lib), lib))

base = None

## Lets not open the console while running the app
if sys.platform == "win32":
    base = "Win32GUI"

executables = [
    Executable(
                "test.py",
                #base=base,
                base="Console",
                targetName = 'test.exe',
                shortcutName="test Player",
                shortcutDir="DesktopFolder",
    )
]

buildOptions = dict(
    compressed = False,
    includes = ['gi._glib'],
    excludes = [],
    packages = [],
    silent=False,
    include_files = include_files,
    icon = 'test.ico',
    namespace_packages = 'gi.overrides',
    copy_dependent_files = True
    )

setup(
    name = "Test",
    author = "Simon Warwick",
    version = "0.0.0",
    description = "Test Player",
    options = dict(build_exe = buildOptions),
    executables = executables
)
我遇到的其他一些问题:

  • Gnome主dll需要转到安装包的根目录

  • Gnome库文件(gstreamer-1.0 DLL和girepository-1.0 typelibs)需要相对位于安装包中

  • 具体包括gi。需要glib

  • 在Gstreamer python脚本中,“filesrc”中的任何文件路径只有在应用程序冻结时才能作为字符串传递(与之相反) (到unicode)

  • 使用“get_property”属性检索gstreamer对象数据(就像对filesrc使用“location”)会神秘地切换到 冻结时需要3个参数,所以我幸运地找到了解决方法 就是使用get_properties()并从它的 名单


  • 这是我目前所能记得的,但如果我了解更多,我会更新列表。

    Heh,是的,我真的不明白为什么或者背景是什么,但所有GStreamer dll和内容都放在python27/lib/site packages/gnome/中的文件夹。。。我试图直接从gstreamer安装路径中提取该内容,但我遇到了模糊不清的丢失模块错误,我无法费心去弄清楚到底发生了什么。也许有人有更有效的方法。。?