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: |
|
run: |
|
||||||
python -m pip install --upgrade pip
|
python -m pip install --upgrade pip
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
# 确保安装tkinterdnd2
|
|
||||||
pip install tkinterdnd2>=0.4.2
|
pip install tkinterdnd2>=0.4.2
|
||||||
pip install pyinstaller
|
pip install pyinstaller
|
||||||
|
|
||||||
# 创建启动器脚本
|
# 创建启动器脚本
|
||||||
- name: Create launcher script
|
- name: Create launcher script
|
||||||
run: |
|
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
|
type gui.py >> launcher.py
|
||||||
|
|
||||||
- name: Build with PyInstaller
|
- name: Build with PyInstaller
|
||||||
run: |
|
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
|
- name: Upload Release Asset
|
||||||
uses: softprops/action-gh-release@v1
|
uses: softprops/action-gh-release@v1
|
||||||
|
30
gui.py
30
gui.py
@ -28,27 +28,17 @@ else: # Linux or others
|
|||||||
class FFmpegInstaller:
|
class FFmpegInstaller:
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_ffmpeg_path():
|
def get_ffmpeg_path():
|
||||||
"""获取FFmpeg可执行文件路径"""
|
if getattr(sys, "frozen", False):
|
||||||
try:
|
# 运行在 PyInstaller 打包后的环境
|
||||||
# 获取程序运行路径
|
return os.path.join(sys._MEIPASS, "ffmpeg")
|
||||||
if getattr(sys, "frozen", False):
|
else:
|
||||||
# PyInstaller打包后的路径
|
# 运行在开发环境
|
||||||
base_path = sys._MEIPASS
|
return os.path.join(os.path.dirname(os.path.abspath(__file__)), "ffmpeg")
|
||||||
else:
|
|
||||||
# 开发环境路径
|
|
||||||
base_path = os.path.dirname(os.path.abspath(__file__))
|
|
||||||
|
|
||||||
# FFmpeg路径
|
# 设置 FFmpeg 路径
|
||||||
ffmpeg_dir = os.path.join(base_path, "ffmpeg")
|
ffmpeg_path = get_ffmpeg_path()
|
||||||
if platform.system().lower() == "windows":
|
if ffmpeg_path not in os.environ["PATH"]:
|
||||||
ffmpeg_path = os.path.join(ffmpeg_dir, "ffmpeg.exe")
|
os.environ["PATH"] = ffmpeg_path + os.pathsep + os.environ["PATH"]
|
||||||
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
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def check_ffmpeg():
|
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平台依赖
|
# Windows平台依赖
|
||||||
tkinterdnd2>=0.4.2; platform_system=="Windows"
|
tkinterdnd2>=0.4.2; platform_system=="Windows"
|
||||||
# Mac平台可以使用其他方案,暂时不需要特殊依赖
|
# 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