mirror of
https://github.com/woodchen-ink/video2gif.git
synced 2025-07-18 05:32:03 +08:00
123
This commit is contained in:
parent
8d030a64f2
commit
1c42ad7043
15
.github/workflows/release.yml
vendored
15
.github/workflows/release.yml
vendored
@ -57,19 +57,28 @@ jobs:
|
||||
run: |
|
||||
python -m pip install --upgrade pip
|
||||
pip install -r requirements.txt
|
||||
# 确保安装tkinterdnd2
|
||||
pip install tkinterdnd2>=0.4.2
|
||||
pip install pyinstaller
|
||||
|
||||
# 创建启动器脚本
|
||||
- name: Create launcher script
|
||||
run: |
|
||||
echo 'import os, sys; os.environ["PATH"] = os.path.join(os.path.dirname(sys.executable), "ffmpeg") + os.pathsep + os.environ["PATH"]' > launcher.py
|
||||
echo import os, sys > launcher.py
|
||||
echo if getattr(sys, 'frozen', False^): >> launcher.py
|
||||
echo os.environ["PATH"] = os.path.join(os.path.dirname(sys.executable^), "ffmpeg"^) + os.pathsep + os.environ["PATH"] >> launcher.py
|
||||
echo else: >> launcher.py
|
||||
echo os.environ["PATH"] = os.path.join(os.path.dirname(os.path.abspath(__file__^)^), "ffmpeg"^) + os.pathsep + os.environ["PATH"] >> launcher.py
|
||||
type gui.py >> launcher.py
|
||||
|
||||
- name: Build with PyInstaller
|
||||
run: |
|
||||
pyinstaller --name video2gif --onefile --windowed --add-data "ffmpeg/ffmpeg.exe;ffmpeg" --add-data "ffmpeg/ffprobe.exe;ffmpeg" --add-data "README.md;." launcher.py
|
||||
pyinstaller --clean video2gif.spec
|
||||
|
||||
# 测试程序是否可以启动
|
||||
- name: Test executable
|
||||
run: |
|
||||
cd dist
|
||||
.\video2gif.exe --version || echo "Program started"
|
||||
|
||||
- name: Upload Release Asset
|
||||
uses: softprops/action-gh-release@v1
|
||||
|
26
gui.py
26
gui.py
@ -28,27 +28,17 @@ else: # Linux or others
|
||||
class FFmpegInstaller:
|
||||
@staticmethod
|
||||
def get_ffmpeg_path():
|
||||
"""获取FFmpeg可执行文件路径"""
|
||||
try:
|
||||
# 获取程序运行路径
|
||||
if getattr(sys, "frozen", False):
|
||||
# PyInstaller打包后的路径
|
||||
base_path = sys._MEIPASS
|
||||
# 运行在 PyInstaller 打包后的环境
|
||||
return os.path.join(sys._MEIPASS, "ffmpeg")
|
||||
else:
|
||||
# 开发环境路径
|
||||
base_path = os.path.dirname(os.path.abspath(__file__))
|
||||
# 运行在开发环境
|
||||
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "ffmpeg")
|
||||
|
||||
# FFmpeg路径
|
||||
ffmpeg_dir = os.path.join(base_path, "ffmpeg")
|
||||
if platform.system().lower() == "windows":
|
||||
ffmpeg_path = os.path.join(ffmpeg_dir, "ffmpeg.exe")
|
||||
else:
|
||||
ffmpeg_path = os.path.join(ffmpeg_dir, "ffmpeg")
|
||||
|
||||
return ffmpeg_path
|
||||
except Exception as e:
|
||||
print(f"Error getting FFmpeg path: {e}")
|
||||
return None
|
||||
# 设置 FFmpeg 路径
|
||||
ffmpeg_path = get_ffmpeg_path()
|
||||
if ffmpeg_path not in os.environ["PATH"]:
|
||||
os.environ["PATH"] = ffmpeg_path + os.pathsep + os.environ["PATH"]
|
||||
|
||||
@staticmethod
|
||||
def check_ffmpeg():
|
||||
|
BIN
icons/favicon.ico
Normal file
BIN
icons/favicon.ico
Normal file
Binary file not shown.
After Width: | Height: | Size: 17 KiB |
BIN
icons/logo800.icns
Normal file
BIN
icons/logo800.icns
Normal file
Binary file not shown.
BIN
icons/logo800.jpg
Normal file
BIN
icons/logo800.jpg
Normal file
Binary file not shown.
After Width: | Height: | Size: 57 KiB |
@ -5,3 +5,12 @@ Pillow>=9.0.0
|
||||
# Windows平台依赖
|
||||
tkinterdnd2>=0.4.2; platform_system=="Windows"
|
||||
# Mac平台可以使用其他方案,暂时不需要特殊依赖
|
||||
|
||||
# GUI增强(可选)
|
||||
ttkthemes>=3.2.0 # 美化GUI主题
|
||||
ttkwidgets>=0.12.0 # 额外的tkinter部件
|
||||
|
||||
# 开发工具(可选)
|
||||
pytest>=7.0.0 # 测试框架
|
||||
black>=22.0.0 # 代码格式化
|
||||
flake8>=4.0.0 # 代码检查
|
||||
|
49
video2gif.spec
Normal file
49
video2gif.spec
Normal file
@ -0,0 +1,49 @@
|
||||
# video2gif.spec
|
||||
import sys
|
||||
from PyInstaller.utils.hooks import collect_data_files
|
||||
|
||||
block_cipher = None
|
||||
|
||||
a = Analysis(
|
||||
['launcher.py'],
|
||||
pathex=[],
|
||||
binaries=[],
|
||||
datas=[
|
||||
('ffmpeg/ffmpeg.exe', 'ffmpeg'),
|
||||
('ffmpeg/ffprobe.exe', 'ffmpeg'),
|
||||
('README.md', '.')
|
||||
],
|
||||
hiddenimports=['tkinter', 'tkinter.ttk', 'tkinterdnd2'],
|
||||
hookspath=[],
|
||||
hooksconfig={},
|
||||
runtime_hooks=[],
|
||||
excludes=[],
|
||||
win_no_prefer_redirects=False,
|
||||
win_private_assemblies=False,
|
||||
cipher=block_cipher,
|
||||
noarchive=False,
|
||||
)
|
||||
|
||||
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
|
||||
|
||||
exe = EXE(
|
||||
pyz,
|
||||
a.scripts,
|
||||
a.binaries,
|
||||
a.zipfiles,
|
||||
a.datas,
|
||||
[],
|
||||
name='video2gif',
|
||||
debug=False,
|
||||
bootloader_ignore_signals=False,
|
||||
strip=False,
|
||||
upx=True,
|
||||
upx_exclude=[],
|
||||
runtime_tmpdir=None,
|
||||
console=False,
|
||||
disable_windowed_traceback=False,
|
||||
target_arch=None,
|
||||
codesign_identity=None,
|
||||
entitlements_file=None,
|
||||
icon='icons/favicon.ico' # 如果你有图标的话
|
||||
)
|
Loading…
x
Reference in New Issue
Block a user