Skip to content

Commit

Permalink
Attempt to build windows binary with ffmpeg bundled
Browse files Browse the repository at this point in the history
  • Loading branch information
beveradb committed Dec 21, 2023
1 parent c643fa6 commit bbb15b9
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 19 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,18 @@ jobs:
with:
python-version: '3.9'

- name: wget
uses: wei/wget@v1
with:
args: -O platform/ffmpeg.exe https://github.com/karaokenerds/karaoke-prep/releases/download/v0.8.3/ffmpeg.exe

- name: Install dependencies with Poetry
run: |
pip install poetry
poetry install
- name: Build EXE with PyInstaller
run: poetry run pyinstaller --onefile karaoke-prep.spec
run: poetry run pyinstaller karaoke-prep.spec

- name: Upload EXE as Artifact
uses: actions/upload-artifact@v2
Expand Down
16 changes: 5 additions & 11 deletions karaoke-prep.spec
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
a = Analysis(
['karaoke_prep/utils/prep_cli.py'],
pathex=[],
binaries=[],
binaries=[('platform/ffmpeg.exe', '.')],
datas=[],
hiddenimports=[],
hookspath=[],
Expand All @@ -18,26 +18,20 @@ pyz = PYZ(a.pure)
exe = EXE(
pyz,
a.scripts,
a.binaries,
a.datas,
[],
exclude_binaries=True,
name='karaoke-prep',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
upx_exclude=[],
runtime_tmpdir=None,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.datas,
strip=False,
upx=True,
upx_exclude=[],
name='karaoke-prep',
)
7 changes: 5 additions & 2 deletions karaoke_prep/karaoke_finalise/karaoke_finalise.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os
import subprocess
import sys
import tempfile
import logging

Expand All @@ -26,7 +26,10 @@ def __init__(

self.logger.debug(f"KaraokeFinalise instantiating")

self.ffmpeg_base_command = "ffmpeg -hide_banner -nostats"
# Path to the Windows PyInstaller frozen bundled ffmpeg.exe, or the system-installed FFmpeg binary on Mac/Linux
ffmpeg_path = os.path.join(sys._MEIPASS, "ffmpeg.exe") if getattr(sys, "frozen", False) else "ffmpeg"

self.ffmpeg_base_command = f"{ffmpeg_path} -hide_banner -nostats"

if self.log_level == logging.DEBUG:
self.ffmpeg_base_command += " -loglevel verbose"
Expand Down
12 changes: 7 additions & 5 deletions karaoke_prep/karaoke_prep.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import re
import glob
import yt_dlp
Expand Down Expand Up @@ -62,7 +63,10 @@ def __init__(
self.denoise_enabled = denoise_enabled
self.create_track_subfolders = create_track_subfolders

self.ffmpeg_base_command = "ffmpeg -hide_banner -nostats"
# Path to the Windows PyInstaller frozen bundled ffmpeg.exe, or the system-installed FFmpeg binary on Mac/Linux
ffmpeg_path = os.path.join(sys._MEIPASS, "ffmpeg.exe") if getattr(sys, "frozen", False) else "ffmpeg"

self.ffmpeg_base_command = f"{ffmpeg_path} -hide_banner -nostats"

if self.log_level == logging.DEBUG:
self.ffmpeg_base_command += " -loglevel verbose"
Expand Down Expand Up @@ -401,11 +405,9 @@ def create_title_video(self, artist, title, format, output_image_filepath, outpu
draw = ImageDraw.Draw(background)

# Accessing the font file from the package resources
with pkg_resources.path('karaoke_prep.resources', format['intro_font']) as font_path:
with pkg_resources.path("karaoke_prep.resources", format["intro_font"]) as font_path:
# Calculate positions and sizes for title and artist
title_font, _ = self.calculate_text_size_and_position(
draw, title, str(font_path), initial_font_size, resolution, title_padding
)
title_font, _ = self.calculate_text_size_and_position(draw, title, str(font_path), initial_font_size, resolution, title_padding)
artist_font, _ = self.calculate_text_size_and_position(
draw, artist, str(font_path), initial_font_size, resolution, artist_padding
)
Expand Down
Empty file added platform/.gitkeep
Empty file.

0 comments on commit bbb15b9

Please sign in to comment.