Compare commits

...
30 Commits
Author SHA1 Message Date
Andrew Beveridge 481a57e0e1 Downgrade torch for now 2025-01-28 14:55:38 -05:00
Andrew Beveridge af5db142ef Move output files from transcriber to parent dir 2025-01-28 14:10:30 -05:00
Andrew Beveridge 54a48cef39 Bumped version for release 2025-01-28 01:00:33 -05:00
Andrew Beveridge 1663f229a3 Improved error handling with invalid inputs 2025-01-28 00:27:00 -05:00
Andrew Beveridge 87ed4799e5 Fixed parameters for integration with LyricsTranscriber 2025-01-27 23:47:04 -05:00
Andrew Beveridge a7a96f2f4b Added non-interactive mode to finalise 2025-01-22 17:37:33 -05:00
Andrew Beveridge 07ee85b304 Made work with MKV input 2025-01-20 00:16:43 -05:00
Andrew Beveridge 595fbbc4e2 Fixed filepaths to copy after moving org dir 2025-01-17 10:40:41 -05:00
Andrew Beveridge dfdbd92269 Added --keep-brand-code param 2025-01-17 01:13:09 -05:00
Andrew Beveridge 78f8880922 Added more output files to CLI output, copy youtube URL and folder sharing link to clipboard automatically 2025-01-15 11:48:24 -05:00
Andrew Beveridge 17be398a0f Reordered remuxing to leave no unnecessarily large files whilst retaining pure PCM audio in all output MP4 files 2025-01-14 21:27:40 -05:00
Andrew Beveridge ee9958bfe9 Improved text rendering size calculation to make text fill more of the region bounding box areas 2024-12-28 04:08:56 -05:00
Andrew Beveridge fc5eabb588 Added gradients, text transforms, and better font size calculation 2024-12-28 03:34:31 -05:00
Andrew Beveridge 4883a93603 Added support for configurable gradients and text transforms 2024-12-28 03:09:00 -05:00
Andrew Beveridge 5d8b697c61 Made styles configurable by JSON config file with combined config for prep and CDG in finalise, etc. 2024-12-28 02:30:09 -05:00
Andrew Beveridge 94ea24bfea Moved lyrics processing into LyricsTranscriber, added MKV output file with lossless audio, used that for upload to YouTube to improve audio quality 2024-12-27 16:00:12 -05:00
Andrew Beveridge 42fc646954 Fixed broken return in separation, transcriber dependency 2024-12-27 01:55:16 -05:00
Andrew Beveridge bd6db70bcf Updated dependencies, modified prep to use latest version of transcriber and rely on lyrics outputs from that rather than duplicating genius fetch logic etc. 2024-12-27 01:29:52 -05:00
Andrew Beveridge 242c1e03ac Improved cdg maker to have configurable styles 2024-12-26 00:03:50 -05:00
Andrew Beveridge ade7c40af7 Updated to check for fonts in the fonts dir 2024-12-25 00:31:03 -05:00
Andrew Beveridge 162faa9189 Updated cdg generation to use parameters 2024-12-25 00:05:24 -05:00
Andrew Beveridge 7ad1ae8305 Updated to newer karaoke-lyrics-processor with clipboard bug fix 2024-12-24 03:29:44 -05:00
Andrew Beveridge 7852619403 Renamed local output file to Original 2024-12-24 02:17:33 -05:00
Andrew Beveridge ddb70a9c31 Updated to include fixed region and extra text logic, additional font, test for intro and end screen rendering 2024-12-24 00:34:28 -05:00
Andrew Beveridge f9336590fa Updated artist title rendering with region logic 2024-12-23 22:40:37 -05:00
Andrew Beveridge 4151650a90 Fixed combined backing instrumental normalization, added anti-duplicate effort existing file checks 2024-12-07 23:56:23 -05:00
Andrew Beveridge 2c1e9f38f7 Bumped version for fixed release 2024-12-07 16:20:09 -05:00
Andrew Beveridge 164b0309ab Fixed youtube and gmail token scopes 2024-12-07 16:19:55 -05:00
Andrew Beveridge ca080e53a0 Added gmail draft 2024-12-07 02:23:20 -05:00
Andrew Beveridge 7776365c80 Added working re-combination of instrumental+bv 2024-12-07 02:03:48 -05:00
21 changed files with 4693 additions and 2245 deletions

No files matched your search

+1
View File
@@ -6,6 +6,7 @@
audio/
lyrics/
karaoke/
tests/outputs
# Byte-compiled / optimized / DLL files
+32 -20
View File
@@ -1558,8 +1558,8 @@ class KaraokeComposer:
background_image = self._load_image(
self.config.title_screen_background,
[
(17, 20, 39), # background
(255, 170, 204), # border
self.config.background, # background
self.config.border, # border
self.config.title_color, # title color
self.config.artist_color, # artist color
],
@@ -1591,6 +1591,9 @@ class KaraokeComposer:
)
y += int(bigfont.size)
# Add vertical gap between title and artist using configured value
y += self.config.title_artist_gap
# Draw song artist
for image in render_lines(
get_wrapped_text(
@@ -1650,13 +1653,14 @@ class KaraokeComposer:
# Queue background image packets (and apply transition)
transition = Image.open(
package_dir / "transitions" / "cdgtitlescreenwipepatternnomad.png"
package_dir / "transitions" / f"{self.config.title_screen_transition}.png"
)
for coord in self._gradient_to_tile_positions(transition):
self.writer.queue_packets(packets.get(coord, []))
INTRO_DURATION = 5 * CDG_FPS # 5 seconds * 300 frames per second = 1500 frames
FIRST_SYLLABLE_BUFFER = 3 * CDG_FPS # 3 seconds * 300 frames per second = 900 frames
# Replace hardcoded values with configured ones
INTRO_DURATION = int(self.config.intro_duration_seconds * CDG_FPS)
FIRST_SYLLABLE_BUFFER = int(self.config.first_syllable_buffer_seconds * CDG_FPS)
# Queue the intro screen for 5 seconds
end_time = INTRO_DURATION
@@ -1673,14 +1677,14 @@ class KaraokeComposer:
logger.debug(f"first syllable starts at {first_syllable_start_offset}")
MINIMUM_FIRST_SYLLABLE_TIME_FOR_NO_SILENCE = INTRO_DURATION + FIRST_SYLLABLE_BUFFER
# If the first syllable is within 8 seconds, add 5 seconds of silence
# If the first syllable is within buffer+intro time, add silence
# Otherwise, don't add any silence
if first_syllable_start_offset < MINIMUM_FIRST_SYLLABLE_TIME_FOR_NO_SILENCE:
self.intro_delay = MINIMUM_FIRST_SYLLABLE_TIME_FOR_NO_SILENCE
logger.info(f"First syllable within 8 seconds. Adding {self.intro_delay} frames of silence.")
logger.info(f"First syllable within {self.config.intro_duration_seconds + self.config.first_syllable_buffer_seconds} seconds. Adding {self.intro_delay} frames of silence.")
else:
self.intro_delay = 0
logger.info("First syllable after 8 seconds. No additional silence needed.")
logger.info("First syllable after buffer period. No additional silence needed.")
def _compose_outro(self, end: int):
# TODO Make it so the outro screen is not hardcoded
@@ -1692,12 +1696,12 @@ class KaraokeComposer:
logger.debug("loading outro background image")
# Load background image
background_image = self._load_image(
self.config.title_screen_background,
self.config.outro_background,
[
(17, 20, 39), # background
(255, 170, 204), # border
self.config.artist_color, # "Thank you for singing" color
self.config.title_color, # "nomadkaraoke.com" color
self.config.background, # background
self.config.border, # border
self.config.outro_line1_color,
self.config.outro_line2_color,
],
)
@@ -1709,33 +1713,41 @@ class KaraokeComposer:
text_image = Image.new("P", (CDG_VISIBLE_WIDTH, MAX_HEIGHT * 2), 0)
y = 0
# Render "Thank you for singing" text
# Render first line of outro text
outro_text_line1 = self.config.outro_text_line1.replace("$artist", self.config.artist).replace("$title", self.config.title)
for image in render_lines(
get_wrapped_text(
"THANK YOU FOR SINGING!",
outro_text_line1,
font=smallfont,
width=text_image.width,
).split("\n"),
font=smallfont,
):
text_image.paste(
image.point(lambda v: v and 2, "P"), # Use index 2 for artist color
image.point(lambda v: v and 2, "P"), # Use index 2 for line 1 color
((text_image.width - image.width) // 2, y),
mask=image.point(lambda v: v and 255, "1"),
)
y += int(smallfont.size)
# Render "nomadkaraoke.com" text
# Add vertical gap between title and artist using configured value
y += self.config.outro_line1_line2_gap
# Render second line of outro text
outro_text_line2 = self.config.outro_text_line2.replace("$artist", self.config.artist).replace("$title", self.config.title)
for image in render_lines(
get_wrapped_text(
"nomadkaraoke.com",
outro_text_line2,
font=smallfont,
width=text_image.width,
).split("\n"),
font=smallfont,
):
text_image.paste(
image.point(lambda v: v and 3, "P"), # Use index 3 for title color
image.point(lambda v: v and 3, "P"), # Use index 3 for line 2 color
((text_image.width - image.width) // 2, y),
mask=image.point(lambda v: v and 255, "1"),
)
@@ -1775,7 +1787,7 @@ class KaraokeComposer:
# Queue background image packets (and apply transition)
transition = Image.open(
package_dir / "transitions" / "cdgtitlescreenwipepatternnomad.png"
package_dir / "transitions" / f"{self.config.outro_transition}.png"
)
for coord in self._gradient_to_tile_positions(transition):
self.writer.queue_packets(packets.get(coord, []))
+29 -9
View File
@@ -8,10 +8,14 @@ from PIL import ImageColor
# NOTE RGBColor is specifically an RGB 3-tuple (red, green, blue).
RGBColor: TypeAlias = tuple[int, int, int]
def to_rgbcolor(val: Any) -> RGBColor:
if isinstance(val, str):
return ImageColor.getrgb(val)[:3]
raise TypeError("color value not convertible to RGBColor")
def to_rgbcolor_or_none(val: Any) -> RGBColor | None:
if val is None or val == "":
return None
@@ -76,10 +80,10 @@ class SettingsInstrumental:
@define
class SettingsSinger:
active_fill: RGBColor = field(converter=to_rgbcolor, default="#33f")
active_stroke: RGBColor = field(converter=to_rgbcolor, default="#004")
inactive_fill: RGBColor = field(converter=to_rgbcolor, default="#ddf")
inactive_stroke: RGBColor = field(converter=to_rgbcolor, default="#009")
active_fill: RGBColor = field(converter=to_rgbcolor, default="#000")
active_stroke: RGBColor = field(converter=to_rgbcolor, default="#000")
inactive_fill: RGBColor = field(converter=to_rgbcolor, default="#000")
inactive_stroke: RGBColor = field(converter=to_rgbcolor, default="#000")
@define
@@ -100,6 +104,7 @@ class Settings:
file: Path
font: Path
title_screen_background: Path
outro_background: Path
outname: str = "output"
clear_mode: LyricClearMode = LyricClearMode.LINE_DELAYED
@@ -118,14 +123,29 @@ class Settings:
singers: list[SettingsSinger] = field(factory=list)
lyrics: list[SettingsLyric] = field(factory=list)
title_color: RGBColor = field(converter=to_rgbcolor, default="#ffffff")
artist_color: RGBColor = field(converter=to_rgbcolor, default="#ffdf6b")
artist_color: RGBColor = field(converter=to_rgbcolor, default="#ffffff")
title_screen_transition: str = "centertexttoplogobottomtext"
title_artist_gap: int = 30
intro_duration_seconds: float = 5.0
first_syllable_buffer_seconds: float = 3.0
outro_transition: str = "centertexttoplogobottomtext"
outro_text_line1: str = "THANK YOU FOR SINGING!"
outro_text_line2: str = "nomadkaraoke.com"
outro_line1_line2_gap: int = 30
outro_line1_color: RGBColor = field(converter=to_rgbcolor, default="#ffffff")
outro_line2_color: RGBColor = field(converter=to_rgbcolor, default="#ffffff")
__all__ = [
"RGBColor",
"LyricClearMode", "TextAlign", "TextPlacement", "StrokeType",
"SettingsInstrumental", "SettingsSinger", "SettingsLyric",
"LyricClearMode",
"TextAlign",
"TextPlacement",
"StrokeType",
"SettingsInstrumental",
"SettingsSinger",
"SettingsLyric",
"Settings",
]
Binary file not shown.
Binary file not shown.
Binary file not shown.
+219 -103
View File
@@ -7,55 +7,17 @@ import argparse
from pathlib import Path
from cdgmaker.composer import KaraokeComposer
import sys
from PIL import ImageFont, Image
from PIL import ImageFont
from cdgmaker.render import get_wrapped_text
import itertools
# Constants for TOML configuration
CLEAR_MODE = "eager"
BACKGROUND_COLOR = "#111427"
BORDER_COLOR = "#111427"
FONT_SIZE = 18
STROKE_WIDTH = 0
STROKE_STYLE = "octagon"
ACTIVE_FILL = "#7070F7"
ACTIVE_STROKE = "#000000"
INACTIVE_FILL = "#ff7acc"
INACTIVE_STROKE = "#000000"
import os
import json
# Keep only the truly constant values that aren't style-related
CDG_VISIBLE_WIDTH = 280
TITLE_COLOR = "#ffffff"
ARTIST_COLOR = "#ffdf6b"
FONT = "/Users/andrew/AvenirNext-Bold.ttf"
TITLE_SCREEN_BACKGROUND = "/Users/andrew/cdg-title-screen-background-nomad-simple.png"
# Instead, create a logger specific to this module
# Create a logger specific to this module
logger = logging.getLogger(__name__)
# Add new constants for default values
DEFAULT_ROW = 4 # Increased from 1 to move text lower
DEFAULT_LINE_TILE_HEIGHT = 3
DEFAULT_LINES_PER_PAGE = 4
# Add new constants for instrumentals
INSTRUMENTAL_GAP_THRESHOLD = 1500 # 15 seconds in centiseconds
DEFAULT_INSTRUMENTAL_TEXT = "INSTRUMENTAL"
# Add these constants near the top of the file, with the other constants
INSTRUMENTAL_BACKGROUND = "/Users/andrew/cdg-instrumental-background-nomad-notes.png"
INSTRUMENTAL_TRANSITION = "cdginstrumentalwipepatternnomad"
INSTRUMENTAL_FONT_COLOR = "#ffdf6b"
# Add this constant near the top of the file with other constants
LEAD_IN_THRESHOLD = 300 # 3 seconds in centiseconds
LEAD_IN_OFFSET = 200 # 2 seconds in centiseconds
# Modify these constants near the top of the file
LEAD_IN_SYMBOLS = ["/>", ">", ">", ">"]
LEAD_IN_DURATION = 30 # 300 ms in centiseconds
LEAD_IN_TOTAL = 200 # 2 seconds in centiseconds
def parse_lrc(lrc_file):
with open(lrc_file, "r", encoding="utf-8") as f:
@@ -81,27 +43,35 @@ def parse_lrc(lrc_file):
return lyrics
def detect_instrumentals(lyrics_data):
def detect_instrumentals(
lyrics_data,
line_tile_height,
instrumental_font_color,
instrumental_background,
instrumental_transition,
instrumental_gap_threshold,
instrumental_text,
):
instrumentals = []
for i in range(len(lyrics_data) - 1):
current_end = lyrics_data[i]["timestamp"]
next_start = lyrics_data[i + 1]["timestamp"]
gap = next_start - current_end
if gap >= INSTRUMENTAL_GAP_THRESHOLD:
if gap >= instrumental_gap_threshold:
instrumental_start = current_end + 200 # Add 2 seconds (200 centiseconds) delay
instrumental_duration = (gap - 200) // 100 # Convert to seconds
instrumentals.append(
{
"sync": instrumental_start,
"wait": True,
"text": f"{DEFAULT_INSTRUMENTAL_TEXT}\n{instrumental_duration} seconds\n",
"text": f"{instrumental_text}\n{instrumental_duration} seconds\n",
"text_align": "center",
"text_placement": "bottom middle",
"line_tile_height": DEFAULT_LINE_TILE_HEIGHT,
"fill": INSTRUMENTAL_FONT_COLOR,
"line_tile_height": line_tile_height,
"fill": instrumental_font_color,
"stroke": "",
"image": INSTRUMENTAL_BACKGROUND,
"transition": INSTRUMENTAL_TRANSITION,
"image": instrumental_background,
"transition": instrumental_transition,
}
)
logger.info(
@@ -112,7 +82,104 @@ def detect_instrumentals(lyrics_data):
return instrumentals
def generate_toml(lrc_file, audio_file, title, artist, output_file, row, line_tile_height, lines_per_page, title_color, artist_color):
def generate_toml(
lrc_file,
audio_file,
title,
artist,
output_file,
cdg_styles,
):
"""
Generate a TOML configuration file for CDG creation.
Args:
cdg_styles (dict): Must contain all style-related parameters:
- title_color
- artist_color
- background_color
- border_color
- font_path
- font_size
- stroke_width
- stroke_style
- active_fill
- active_stroke
- inactive_fill
- inactive_stroke
- title_screen_background
- instrumental_background
- instrumental_transition
- instrumental_font_color
- title_screen_transition
- row
- line_tile_height
- lines_per_page
- clear_mode
- sync_offset
- instrumental_gap_threshold
- instrumental_text
- lead_in_threshold
- lead_in_symbols
- lead_in_duration
- lead_in_total
- title_artist_gap
- intro_duration_seconds
- first_syllable_buffer_seconds
- outro_background
- outro_transition
- outro_text_line1
- outro_text_line2
- outro_line1_color
- outro_line2_color
- outro_line1_line2_gap
"""
# Validate required style parameters
required_styles = {
"title_color",
"artist_color",
"background_color",
"border_color",
"font_path",
"font_size",
"stroke_width",
"stroke_style",
"active_fill",
"active_stroke",
"inactive_fill",
"inactive_stroke",
"title_screen_background",
"instrumental_background",
"instrumental_transition",
"instrumental_font_color",
"title_screen_transition",
"row",
"line_tile_height",
"lines_per_page",
"clear_mode",
"sync_offset",
"instrumental_gap_threshold",
"instrumental_text",
"lead_in_threshold",
"lead_in_symbols",
"lead_in_duration",
"lead_in_total",
"title_artist_gap",
"intro_duration_seconds",
"first_syllable_buffer_seconds",
"outro_background",
"outro_transition",
"outro_text_line1",
"outro_text_line2",
"outro_line1_color",
"outro_line2_color",
"outro_line1_line2_gap",
}
missing_styles = required_styles - set(cdg_styles.keys())
if missing_styles:
raise ValueError(f"Missing required style parameters: {', '.join(missing_styles)}")
try:
lyrics_data = parse_lrc(lrc_file)
except ValueError as e:
@@ -129,11 +196,11 @@ def generate_toml(lrc_file, audio_file, title, artist, output_file, row, line_ti
for i, lyric in enumerate(lyrics_data):
logger.debug(f"Processing lyric {i}: timestamp {lyric['timestamp']}, text '{lyric['text']}'")
if i == 0 or lyric["timestamp"] - lyrics_data[i - 1]["timestamp"] >= LEAD_IN_THRESHOLD:
lead_in_start = lyric["timestamp"] - LEAD_IN_TOTAL
if i == 0 or lyric["timestamp"] - lyrics_data[i - 1]["timestamp"] >= cdg_styles["lead_in_threshold"]:
lead_in_start = lyric["timestamp"] - cdg_styles["lead_in_total"]
logger.debug(f"Adding lead-in before lyric {i} at timestamp {lead_in_start}")
for j, symbol in enumerate(LEAD_IN_SYMBOLS):
sync_time = lead_in_start + j * LEAD_IN_DURATION
for j, symbol in enumerate(cdg_styles["lead_in_symbols"]):
sync_time = lead_in_start + j * cdg_styles["lead_in_duration"]
sync_times.append(sync_time)
formatted_lyrics.append(symbol)
logger.debug(f" Added lead-in symbol {j+1}: '{symbol}' at {sync_time}")
@@ -142,52 +209,77 @@ def generate_toml(lrc_file, audio_file, title, artist, output_file, row, line_ti
formatted_lyrics.append(lyric["text"])
logger.debug(f"Added lyric: '{lyric['text']}' at {lyric['timestamp']}")
instrumentals = detect_instrumentals(lyrics_data)
formatted_lyrics = format_lyrics(formatted_lyrics, instrumentals, sync_times)
instrumentals = detect_instrumentals(
lyrics_data,
line_tile_height=cdg_styles["line_tile_height"],
instrumental_font_color=cdg_styles["instrumental_font_color"],
instrumental_background=cdg_styles["instrumental_background"],
instrumental_transition=cdg_styles["instrumental_transition"],
instrumental_gap_threshold=cdg_styles["instrumental_gap_threshold"],
instrumental_text=cdg_styles["instrumental_text"],
)
formatted_lyrics = format_lyrics(
formatted_lyrics, instrumentals, sync_times, font_path=cdg_styles["font_path"], font_size=cdg_styles["font_size"]
)
toml_data = {
"title": title,
"artist": artist,
"file": audio_file,
"outname": Path(lrc_file).stem,
"clear_mode": CLEAR_MODE,
"sync_offset": 0,
"background": BACKGROUND_COLOR,
"border": BORDER_COLOR,
"font": FONT,
"font_size": FONT_SIZE,
"stroke_width": STROKE_WIDTH,
"stroke_style": STROKE_STYLE,
"clear_mode": cdg_styles["clear_mode"],
"sync_offset": cdg_styles["sync_offset"],
"background": cdg_styles["background_color"],
"border": cdg_styles["border_color"],
"font": cdg_styles["font_path"],
"font_size": cdg_styles["font_size"],
"stroke_width": cdg_styles["stroke_width"],
"stroke_style": cdg_styles["stroke_style"],
"singers": [
{"active_fill": ACTIVE_FILL, "active_stroke": ACTIVE_STROKE, "inactive_fill": INACTIVE_FILL, "inactive_stroke": INACTIVE_STROKE}
{
"active_fill": cdg_styles["active_fill"],
"active_stroke": cdg_styles["active_stroke"],
"inactive_fill": cdg_styles["inactive_fill"],
"inactive_stroke": cdg_styles["inactive_stroke"],
}
],
"lyrics": [
{
"singer": 1,
"sync": sync_times,
"row": row,
"line_tile_height": line_tile_height,
"lines_per_page": lines_per_page,
"row": cdg_styles["row"],
"line_tile_height": cdg_styles["line_tile_height"],
"lines_per_page": cdg_styles["lines_per_page"],
"text": formatted_lyrics,
}
],
"title_color": title_color,
"artist_color": artist_color,
"title_screen_background": TITLE_SCREEN_BACKGROUND,
"title_color": cdg_styles["title_color"],
"artist_color": cdg_styles["artist_color"],
"title_screen_background": cdg_styles["title_screen_background"],
"title_screen_transition": cdg_styles["title_screen_transition"],
"instrumentals": instrumentals,
"intro_duration_seconds": cdg_styles["intro_duration_seconds"],
"first_syllable_buffer_seconds": cdg_styles["first_syllable_buffer_seconds"],
"outro_background": cdg_styles["outro_background"],
"outro_transition": cdg_styles["outro_transition"],
"outro_text_line1": cdg_styles["outro_text_line1"],
"outro_text_line2": cdg_styles["outro_text_line2"],
"outro_line1_color": cdg_styles["outro_line1_color"],
"outro_line2_color": cdg_styles["outro_line2_color"],
"outro_line1_line2_gap": cdg_styles["outro_line1_line2_gap"],
}
with open(output_file, "w", encoding="utf-8") as f:
toml.dump(toml_data, f)
logger.info(f"TOML file generated: {output_file}")
def get_font():
def get_font(font_path=None, font_size=18):
try:
return ImageFont.truetype(FONT, FONT_SIZE)
return ImageFont.truetype(font_path, font_size) if font_path else ImageFont.load_default()
except IOError:
logger.warning(f"Font file {FONT} not found. Using default font.")
logger.warning(f"Font file {font_path} not found. Using default font.")
return ImageFont.load_default()
@@ -220,9 +312,9 @@ def wrap_text(text, max_width, font):
return lines
def format_lyrics(lyrics_data, instrumentals, sync_times):
def format_lyrics(lyrics_data, instrumentals, sync_times, font_path=None, font_size=18):
formatted_lyrics = []
font = get_font()
font = get_font(font_path, font_size)
logger.debug(f"Using font: {font}")
current_line = ""
@@ -292,27 +384,46 @@ def generate_cdg(
audio_file,
title,
artist,
row=DEFAULT_ROW,
line_tile_height=DEFAULT_LINE_TILE_HEIGHT,
lines_per_page=DEFAULT_LINES_PER_PAGE,
title_color=TITLE_COLOR,
artist_color=ARTIST_COLOR,
cdg_styles,
):
"""
Generate a CDG file from an LRC file and audio file.
This function can be called from other Python code to generate CDG files.
Args:
lrc_file (str): Path to the LRC file
audio_file (str): Path to the audio file
title (str): Title of the song
artist (str): Artist of the song
cdg_styles (dict): Dictionary containing all style and layout parameters
"""
# Check if font_path is just a filename and look for it in the package's fonts directory
if cdg_styles["font_path"] and not os.path.isabs(cdg_styles["font_path"]) and not os.path.exists(cdg_styles["font_path"]):
package_font_path = os.path.join(os.path.dirname(__file__), "fonts", cdg_styles["font_path"])
if os.path.exists(package_font_path):
cdg_styles["font_path"] = package_font_path
logger.debug(f"Found font in package fonts directory: {cdg_styles['font_path']}")
else:
logger.warning(f"Font file {cdg_styles['font_path']} not found in package fonts directory, will use default font")
cdg_styles["font_path"] = None
# Set up logging for this function if it hasn't been configured
if not logger.handlers:
handler = logging.StreamHandler()
formatter = logging.Formatter("%(asctime)s - %(name)s - %(levelname)s - %(message)s")
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO) # Set to INFO by default, can be changed
logger.setLevel(logging.INFO)
toml_file = f"{Path(lrc_file).stem}.toml"
generate_toml(lrc_file, audio_file, title, artist, toml_file, row, line_tile_height, lines_per_page, title_color, artist_color)
generate_toml(
lrc_file,
audio_file,
title,
artist,
toml_file,
cdg_styles,
)
try:
kc = KaraokeComposer.from_file(toml_file)
@@ -327,7 +438,6 @@ def cli_main():
"""
Command-line interface entry point for the lrc2cdg tool.
"""
# Set up logging for CLI use
logging.basicConfig(level=logging.INFO, format="%(asctime)s - %(name)s - %(levelname)s - %(message)s")
parser = argparse.ArgumentParser(description="Convert LRC file to CDG")
@@ -335,25 +445,31 @@ def cli_main():
parser.add_argument("audio_file", help="Path to the audio file")
parser.add_argument("--title", required=True, help="Title of the song")
parser.add_argument("--artist", required=True, help="Artist of the song")
parser.add_argument("--row", type=int, default=DEFAULT_ROW, help="Starting row for lyrics (0-17)")
parser.add_argument("--line-tile-height", type=int, default=DEFAULT_LINE_TILE_HEIGHT, help="Height of each line in tile rows")
parser.add_argument("--lines-per-page", type=int, default=DEFAULT_LINES_PER_PAGE, help="Number of lines per page")
parser.add_argument("--title-color", default=TITLE_COLOR, help="Color of the title text on the intro screen")
parser.add_argument("--artist-color", default=ARTIST_COLOR, help="Color of the artist text on the intro screen")
parser.add_argument("--cdg-styles-json", required=True, help="Path to JSON file containing CDG style configuration")
args = parser.parse_args()
generate_cdg(
args.lrc_file,
args.audio_file,
args.title,
args.artist,
args.row,
args.line_tile_height,
args.lines_per_page,
args.title_color,
args.artist_color,
)
try:
with open(args.cdg_styles_json, "r") as f:
cdg_styles = json.loads(f.read())
except FileNotFoundError:
logger.error(f"Style configuration file not found: {args.cdg_styles_json}")
sys.exit(1)
except json.JSONDecodeError as e:
logger.error(f"Invalid JSON in style configuration file: {e}")
sys.exit(1)
try:
generate_cdg(
args.lrc_file,
args.audio_file,
args.title,
args.artist,
cdg_styles,
)
except ValueError as e:
logger.error(f"Invalid style configuration: {e}")
sys.exit(1)
if __name__ == "__main__":
Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

+353 -130
View File
@@ -17,6 +17,9 @@ from googleapiclient.http import MediaFileUpload
import subprocess
import time
from cdgmaker.lrc_to_cdg import generate_cdg
from google.oauth2.credentials import Credentials
import base64
from email.mime.text import MIMEText
class KaraokeFinalise:
@@ -37,6 +40,9 @@ class KaraokeFinalise:
youtube_description_file=None,
rclone_destination=None,
discord_webhook_url=None,
email_template_file=None,
cdg_styles=None,
keep_brand_code=False,
non_interactive=False,
):
self.logger = logging.getLogger(__name__)
@@ -98,15 +104,18 @@ class KaraokeFinalise:
"end_jpg": " (End).jpg",
"with_vocals_mov": " (With Vocals).mov",
"with_vocals_mp4": " (With Vocals).mp4",
"with_vocals_mkv": " (With Vocals).mkv",
"karaoke_lrc": " (Karaoke).lrc",
"karaoke_cdg": " (Karaoke).cdg",
"karaoke_txt": " (Karaoke).txt",
"karaoke_mp3": " (Karaoke).mp3",
"karaoke_mov": " (Karaoke).mov",
"final_karaoke_mp4": " (Final Karaoke).mp4",
"karaoke_mp4": " (Karaoke).mp4",
"final_karaoke_lossless_mp4": " (Final Karaoke Lossless 4k).mp4",
"final_karaoke_lossless_mkv": " (Final Karaoke Lossless 4k).mkv",
"final_karaoke_lossy_mp4": " (Final Karaoke Lossy 4k).mp4",
"final_karaoke_lossy_720p_mp4": " (Final Karaoke Lossy 720p).mp4",
"final_karaoke_cdg_zip": " (Final Karaoke CDG).zip",
"final_karaoke_txt_zip": " (Final Karaoke TXT).zip",
"final_karaoke_720p_mp4": " (Final Karaoke 720p).mp4",
}
self.youtube_url_prefix = "https://www.youtube.com/watch?v="
@@ -117,6 +126,20 @@ class KaraokeFinalise:
self.new_brand_code_dir_path = None
self.brand_code_dir_sharing_link = None
self.email_template_file = email_template_file
self.gmail_service = None
self.cdg_styles = cdg_styles
# Determine best available AAC codec
self.aac_codec = self.detect_best_aac_codec()
self.keep_brand_code = keep_brand_code
# Update ffmpeg base command to include -y if non-interactive
if self.non_interactive:
self.ffmpeg_base_command += " -y"
def check_input_files_exist(self, base_name, with_vocals_file, instrumental_audio_file):
self.logger.info(f"Checking required input files exist...")
@@ -152,11 +175,13 @@ class KaraokeFinalise:
def prepare_output_filenames(self, base_name):
output_files = {
"karaoke_mov": f"{base_name}{self.suffixes['karaoke_mov']}",
"karaoke_mp4": f"{base_name}{self.suffixes['karaoke_mp4']}",
"karaoke_mp3": f"{base_name}{self.suffixes['karaoke_mp3']}",
"with_vocals_mp4": f"{base_name}{self.suffixes['with_vocals_mp4']}",
"final_karaoke_mp4": f"{base_name}{self.suffixes['final_karaoke_mp4']}",
"final_karaoke_720p_mp4": f"{base_name}{self.suffixes['final_karaoke_720p_mp4']}",
"final_karaoke_lossless_mp4": f"{base_name}{self.suffixes['final_karaoke_lossless_mp4']}",
"final_karaoke_lossless_mkv": f"{base_name}{self.suffixes['final_karaoke_lossless_mkv']}",
"final_karaoke_lossy_mp4": f"{base_name}{self.suffixes['final_karaoke_lossy_mp4']}",
"final_karaoke_lossy_720p_mp4": f"{base_name}{self.suffixes['final_karaoke_lossy_720p_mp4']}",
}
if self.enable_cdg:
@@ -169,13 +194,17 @@ class KaraokeFinalise:
return output_files
def prompt_user_confirmation_or_raise_exception(self, prompt_message, exit_message, allow_empty=False):
if self.non_interactive:
self.logger.info(f"Non-interactive mode, automatically confirming: {prompt_message}")
return True
if not self.prompt_user_bool(prompt_message, allow_empty=allow_empty):
self.logger.error(exit_message)
raise Exception(exit_message)
def prompt_user_bool(self, prompt_message, allow_empty=False):
if self.non_interactive:
self.logger.warning(f"Non-interactive mode, responding True for prompt: {prompt_message}")
self.logger.info(f"Non-interactive mode, automatically answering yes to: {prompt_message}")
return True
options_string = "[y]/n" if allow_empty else "y/[n]"
@@ -265,11 +294,11 @@ class KaraokeFinalise:
def authenticate_youtube(self):
"""Authenticate and return a YouTube service object."""
credentials = None
pickle_file = "/tmp/karaoke-finalise-token.pickle"
youtube_token_file = "/tmp/karaoke-finalise-youtube-token.pickle"
# Token file stores the user's access and refresh tokens.
if os.path.exists(pickle_file):
with open(pickle_file, "rb") as token:
# Token file stores the user's access and refresh tokens for YouTube.
if os.path.exists(youtube_token_file):
with open(youtube_token_file, "rb") as token:
credentials = pickle.load(token)
# If there are no valid credentials, let the user log in.
@@ -283,7 +312,7 @@ class KaraokeFinalise:
credentials = flow.run_local_server(port=0) # This will open a browser for authentication
# Save the credentials for the next run
with open(pickle_file, "wb") as token:
with open(youtube_token_file, "wb") as token:
pickle.dump(credentials, token)
return build("youtube", "v3", credentials=credentials)
@@ -339,10 +368,10 @@ class KaraokeFinalise:
return truncated_title
def upload_final_mp4_to_youtube_with_title_thumbnail(self, artist, title, input_files, output_files):
self.logger.info(f"Uploading final MP4 to YouTube with title thumbnail...")
self.logger.info(f"Uploading final MKV to YouTube with title thumbnail...")
if self.dry_run:
self.logger.info(
f'DRY RUN: Would upload {output_files["final_karaoke_mp4"]} to YouTube with thumbnail {input_files["title_jpg"]} using client secrets file: {self.youtube_client_secrets_file}'
f'DRY RUN: Would upload {output_files["final_karaoke_lossless_mkv"]} to YouTube with thumbnail {input_files["title_jpg"]} using client secrets file: {self.youtube_client_secrets_file}'
)
else:
youtube_title = f"{artist} - {title} (Karaoke)"
@@ -377,11 +406,11 @@ class KaraokeFinalise:
"status": {"privacyStatus": "public"},
}
# Use MediaFileUpload to handle the video file
media_file = MediaFileUpload(output_files["final_karaoke_mp4"], mimetype="video/mp4", resumable=True)
# Use MediaFileUpload to handle the video file - using the MKV with FLAC audio
media_file = MediaFileUpload(output_files["final_karaoke_lossless_mkv"], mimetype="video/x-matroska", resumable=True)
# Call the API's videos.insert method to create and upload the video.
self.logger.info(f"Uploading final MP4 to YouTube...")
self.logger.info(f"Uploading final MKV to YouTube...")
request = youtube.videos().insert(part="snippet,status", body=body, media_body=media_file)
response = request.execute()
@@ -425,54 +454,68 @@ class KaraokeFinalise:
self.logger.info("Message posted to Discord")
def find_with_vocals_file(self):
self.logger.info("Finding input file in current directory ending (With Vocals).mov or (With Vocals).mp4")
self.logger.info("Finding input file ending in (With Vocals).mov/.mp4/.mkv or (Karaoke).mov/.mp4/.mkv")
with_vocals_files = [f for f in os.listdir(".") if self.suffixes["with_vocals_mov"] in f]
# Define all possible suffixes for with vocals files
with_vocals_suffixes = [
self.suffixes["with_vocals_mov"],
self.suffixes["with_vocals_mp4"],
self.suffixes["with_vocals_mkv"],
]
if not with_vocals_files:
self.logger.info(f"No with vocals MOV file found, looking for with vocals MP4 file instead")
# First try to find a properly named with vocals file in any supported format
with_vocals_files = [f for f in os.listdir(".") if any(f.endswith(suffix) for suffix in with_vocals_suffixes)]
with_vocals_files = [f for f in os.listdir(".") if self.suffixes["with_vocals_mp4"] in f]
if with_vocals_files:
self.logger.info(f"Found with vocals MP4 file: {with_vocals_files[0]}")
return with_vocals_files[0]
if with_vocals_files:
self.logger.info(f"Found with vocals file: {with_vocals_files[0]}")
return with_vocals_files[0]
if not with_vocals_files:
karaoke_files = [f for f in os.listdir(".") if self.suffixes["karaoke_mov"] in f]
if karaoke_files:
for file in karaoke_files:
new_file = file.replace(self.suffixes["karaoke_mov"], self.suffixes["with_vocals_mov"])
# If no with vocals file found, look for potentially misnamed karaoke files
karaoke_suffixes = [" (Karaoke).mov", " (Karaoke).mp4", " (Karaoke).mkv"]
karaoke_files = [f for f in os.listdir(".") if any(f.endswith(suffix) for suffix in karaoke_suffixes)]
self.prompt_user_confirmation_or_raise_exception(
f"Found '{file}' but no '(With Vocals)', rename to {new_file} for vocal input?",
"Unable to proceed without With Vocals file or user confirmation of rename.",
allow_empty=True,
)
if karaoke_files:
for file in karaoke_files:
# Get the current extension
current_ext = os.path.splitext(file)[1]
base_without_suffix = file.replace(f" (Karaoke){current_ext}", "")
new_file = f"{base_without_suffix}{self.suffixes[f'with_vocals{current_ext[1:]}']}"
os.rename(file, new_file)
self.logger.info(f"Renamed '{file}' to '{new_file}'")
return new_file
else:
raise Exception("No suitable files found for processing.")
else:
return with_vocals_files[0] # Assuming only one such file is expected
self.prompt_user_confirmation_or_raise_exception(
f"Found '{file}' but no '(With Vocals)', rename to {new_file} for vocal input?",
"Unable to proceed without With Vocals file or user confirmation of rename.",
allow_empty=True,
)
os.rename(file, new_file)
self.logger.info(f"Renamed '{file}' to '{new_file}'")
return new_file
raise Exception("No suitable files found for processing.")
def choose_instrumental_audio_file(self, base_name):
self.logger.info(f"Choosing instrumental audio file to use as karaoke audio...")
search_string = " (Instrumental "
search_string = " (Instrumental"
self.logger.info(f"Searching for files in current directory containing {search_string}")
all_instrumental_files = [f for f in os.listdir(".") if search_string in f]
flac_files = set(f.rsplit(".", 1)[0] for f in all_instrumental_files if f.endswith(".flac"))
mp3_files = set(f.rsplit(".", 1)[0] for f in all_instrumental_files if f.endswith(".mp3"))
wav_files = set(f.rsplit(".", 1)[0] for f in all_instrumental_files if f.endswith(".wav"))
self.logger.debug(f"FLAC files found: {flac_files}")
self.logger.debug(f"MP3 files found: {mp3_files}")
self.logger.debug(f"WAV files found: {wav_files}")
# Filter out MP3 files if their FLAC counterpart exists
# Filter out MP3 files if their FLAC or WAV counterpart exists
# Filter out WAV files if their FLAC counterpart exists
filtered_files = [
f for f in all_instrumental_files if f.endswith(".flac") or (f.endswith(".mp3") and f.rsplit(".", 1)[0] not in flac_files)
f
for f in all_instrumental_files
if f.endswith(".flac")
or (f.endswith(".wav") and f.rsplit(".", 1)[0] not in flac_files)
or (f.endswith(".mp3") and f.rsplit(".", 1)[0] not in flac_files and f.rsplit(".", 1)[0] not in wav_files)
]
self.logger.debug(f"Filtered instrumental files: {filtered_files}")
@@ -483,6 +526,11 @@ class KaraokeFinalise:
if len(filtered_files) == 1:
return filtered_files[0]
# In non-interactive mode, always choose the first option
if self.non_interactive:
self.logger.info(f"Non-interactive mode, automatically choosing first instrumental file: {filtered_files[0]}")
return filtered_files[0]
# Sort the remaining instrumental options alphabetically
filtered_files.sort(reverse=True)
@@ -508,7 +556,18 @@ class KaraokeFinalise:
def get_names_from_withvocals(self, with_vocals_file):
self.logger.info(f"Getting artist and title from {with_vocals_file}")
base_name = with_vocals_file.replace(self.suffixes["with_vocals_mov"], "").replace(self.suffixes["with_vocals_mp4"], "")
# Remove both possible suffixes and their extensions
base_name = with_vocals_file
for suffix_key in ["with_vocals_mov", "with_vocals_mp4", "with_vocals_mkv"]:
suffix = self.suffixes[suffix_key]
if suffix in base_name:
base_name = base_name.replace(suffix, "")
break
# If we didn't find a match above, try removing just the extension
if base_name == with_vocals_file:
base_name = os.path.splitext(base_name)[0]
artist, title = base_name.split(" - ", 1)
return base_name, artist, title
@@ -520,27 +579,97 @@ class KaraokeFinalise:
self.logger.info(f"Running command: {command}")
os.system(command)
def remux_with_instrumental(self, with_vocals_file, instrumental_audio, output_file):
"""Remux the video with instrumental audio to create karaoke version"""
# fmt: off
ffmpeg_command = (
f'{self.ffmpeg_base_command} -an -i "{with_vocals_file}" '
f'-vn -i "{instrumental_audio}" -c:v copy -c:a pcm_s16le "{output_file}"'
)
# fmt: on
self.execute_command(ffmpeg_command, "Remuxing video with instrumental audio")
def convert_mov_to_mp4(self, input_file, output_file):
"""Convert MOV file to MP4 format"""
# fmt: off
ffmpeg_command = (
f'{self.ffmpeg_base_command} -i "{input_file}" '
f'-c:v libx264 -c:a {self.aac_codec} "{output_file}"'
)
# fmt: on
self.execute_command(ffmpeg_command, "Converting MOV video to MP4")
def encode_lossless_mp4(self, title_mov_file, karaoke_mp4_file, env_mov_input, ffmpeg_filter, output_file):
"""Create the final MP4 with PCM audio (lossless)"""
# fmt: off
ffmpeg_command = (
f"{self.ffmpeg_base_command} -i {title_mov_file} -i {karaoke_mp4_file} {env_mov_input} "
f'{ffmpeg_filter} -map "[outv]" -map "[outa]" -c:v libx264 -c:a pcm_s16le "{output_file}"'
)
# fmt: on
self.execute_command(ffmpeg_command, "Creating MP4 version with PCM audio")
def encode_lossy_mp4(self, input_file, output_file):
"""Create MP4 with AAC audio (lossy, for wider compatibility)"""
# fmt: off
ffmpeg_command = (
f'{self.ffmpeg_base_command} -i "{input_file}" '
f'-c:v copy -c:a {self.aac_codec} -b:a 320k "{output_file}"'
)
# fmt: on
self.execute_command(ffmpeg_command, "Creating MP4 version with AAC audio")
def encode_lossless_mkv(self, input_file, output_file):
"""Create MKV with FLAC audio (for YouTube)"""
# fmt: off
ffmpeg_command = (
f'{self.ffmpeg_base_command} -i "{input_file}" '
f'-c:v copy -c:a flac "{output_file}"'
)
# fmt: on
self.execute_command(ffmpeg_command, "Creating MKV version with FLAC audio for YouTube")
def encode_720p_version(self, input_file, output_file):
"""Create 720p MP4 with AAC audio (for smaller file size)"""
# fmt: off
ffmpeg_command = (
f'{self.ffmpeg_base_command} -i "{input_file}" '
f'-c:v libx264 -vf "scale=1280:720" -b:v 200k -preset medium -tune animation '
f'-c:a {self.aac_codec} -b:a 128k "{output_file}"'
)
# fmt: on
self.execute_command(ffmpeg_command, "Encoding 720p version of the final video")
def prepare_concat_filter(self, input_files):
"""Prepare the concat filter and additional input for end credits if present"""
env_mov_input = ""
ffmpeg_filter = '-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]"'
if "end_mov" in input_files and os.path.isfile(input_files["end_mov"]):
self.logger.info(f"Found end_mov file: {input_files['end_mov']}, including in final MP4")
end_mov_file = shlex.quote(os.path.abspath(input_files["end_mov"]))
env_mov_input = f"-i {end_mov_file}"
ffmpeg_filter = '-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]"'
return env_mov_input, ffmpeg_filter
def remux_and_encode_output_video_files(self, with_vocals_file, input_files, output_files):
self.logger.info(f"Remuxing and encoding output video files...")
# Check if output files already exist, if so, ask user to overwrite or skip
if os.path.isfile(output_files["karaoke_mov"]) and os.path.isfile(output_files["final_karaoke_mp4"]):
# Check if output files already exist
if os.path.isfile(output_files["final_karaoke_lossless_mp4"]) and os.path.isfile(output_files["final_karaoke_lossless_mkv"]):
if not self.prompt_user_bool(
f"Found existing Final Karaoke output file: {output_files['final_karaoke_mp4']}. Overwrite (y) or skip (n)?",
f"Found existing Final Karaoke output files. Overwrite (y) or skip (n)?",
):
self.logger.info(f"Skipping Karaoke MOV remux and Final MP4 render, existing files will be used.")
self.logger.info(f"Skipping Karaoke MP4 remux and Final video renders, existing files will be used.")
return
# Remux the synced video with the instrumental audio to produce an instrumental karaoke MOV file
remux_ffmpeg_command = f'{self.ffmpeg_base_command} -an -i "{with_vocals_file}" -vn -i "{input_files["instrumental_audio"]}" -c:v copy -c:a aac "{output_files["karaoke_mov"]}"'
self.execute_command(remux_ffmpeg_command, "Remuxing video with instrumental audio")
# Create karaoke version with instrumental audio
self.remux_with_instrumental(with_vocals_file, input_files["instrumental_audio"], output_files["karaoke_mp4"])
# Convert the with vocals video to MP4 if it isn't already
# Convert the with vocals video to MP4 if needed
if not with_vocals_file.endswith(".mp4"):
with_vocals_mp4_command = (
f'{self.ffmpeg_base_command} -i "{with_vocals_file}" -c:v libx264 -c:a aac "{output_files["with_vocals_mp4"]}"'
)
self.execute_command(with_vocals_mp4_command, "Converting with vocals video to MP4")
self.convert_mov_to_mp4(with_vocals_file, output_files["with_vocals_mp4"])
# Delete the with vocals mov after successfully converting it to mp4
if not self.dry_run and os.path.isfile(with_vocals_file):
@@ -549,36 +678,26 @@ class KaraokeFinalise:
# Quote file paths to handle special characters
title_mov_file = shlex.quote(os.path.abspath(input_files["title_mov"]))
karaoke_mov_file = shlex.quote(os.path.abspath(output_files["karaoke_mov"]))
output_final_mp4_file = shlex.quote(output_files["final_karaoke_mp4"])
karaoke_mp4_file = shlex.quote(os.path.abspath(output_files["karaoke_mp4"]))
env_mov_input = ""
ffmpeg_filter = '-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0]concat=n=2:v=1:a=1[outv][outa]"'
# Prepare concat filter for combining videos
env_mov_input, ffmpeg_filter = self.prepare_concat_filter(input_files)
# Check if end_mov file exists and include it in the concat command
if "end_mov" in input_files and os.path.isfile(input_files["end_mov"]):
self.logger.info(f"Found end_mov file: {input_files['end_mov']}, including in final MP4")
end_mov_file = shlex.quote(os.path.abspath(input_files["end_mov"]))
env_mov_input = f"-i {end_mov_file}"
ffmpeg_filter = '-filter_complex "[0:v:0][0:a:0][1:v:0][1:a:0][2:v:0][2:a:0]concat=n=3:v=1:a=1[outv][outa]"'
# Create all output versions
self.encode_lossless_mp4(title_mov_file, karaoke_mp4_file, env_mov_input, ffmpeg_filter, output_files["final_karaoke_lossless_mp4"])
self.encode_lossy_mp4(output_files["final_karaoke_lossless_mp4"], output_files["final_karaoke_lossy_mp4"])
self.encode_lossless_mkv(output_files["final_karaoke_lossless_mp4"], output_files["final_karaoke_lossless_mkv"])
self.encode_720p_version(output_files["final_karaoke_lossless_mp4"], output_files["final_karaoke_lossy_720p_mp4"])
aac_codec = "libfdk_aac"
# Check if aac_at codec is available
codec_check_command = f"{self.ffmpeg_base_command} -codecs"
result = os.popen(codec_check_command).read()
if "aac_at" in result:
aac_codec = "aac_at"
join_ffmpeg_command = f'{self.ffmpeg_base_command} -i {title_mov_file} -i {karaoke_mov_file} {env_mov_input} {ffmpeg_filter} -map "[outv]" -map "[outa]" -c:v libx264 -c:a {aac_codec} -q:a 14 {output_final_mp4_file}'
self.logger.debug(f"Running command: {join_ffmpeg_command}")
self.execute_command(join_ffmpeg_command, "Joining title and instrumental videos")
# Prompt user to check final MP4 file before proceeding
# Prompt user to check final video files before proceeding
self.prompt_user_confirmation_or_raise_exception(
f"Final MP4 file created: {output_files['final_karaoke_mp4']}, please check it! Proceed?",
"Refusing to proceed without user confirmation they're happy with the Final MP4.",
f"Final video files created:\n"
f"- Lossless 4K MP4: {output_files['final_karaoke_lossless_mp4']}\n"
f"- Lossless 4K MKV: {output_files['final_karaoke_lossless_mkv']}\n"
f"- Lossy 4K MP4: {output_files['final_karaoke_lossy_mp4']}\n"
f"- Lossy 720p MP4: {output_files['final_karaoke_lossy_720p_mp4']}\n"
f"Please check them! Proceed?",
"Refusing to proceed without user confirmation they're happy with the Final videos.",
allow_empty=True,
)
@@ -599,36 +718,45 @@ class KaraokeFinalise:
else:
self.logger.info(f"Generating CDG and MP3 files")
generate_cdg(input_files["karaoke_lrc"], input_files["instrumental_audio"], title, artist)
if self.cdg_styles is None:
raise ValueError("CDG styles configuration is required when enable_cdg is True")
# Look for the generated ZIP file
expected_zip = f"{artist} - {title} (Karaoke).zip"
generate_cdg(
input_files["karaoke_lrc"],
input_files["instrumental_audio"],
title,
artist,
self.cdg_styles,
)
self.logger.info(f"Searching for CDG ZIP file. Expected: {expected_zip}")
# Look for the generated ZIP file
expected_zip = f"{artist} - {title} (Karaoke).zip"
if os.path.isfile(expected_zip):
self.logger.info(f"Found expected CDG ZIP file: {expected_zip}")
os.rename(expected_zip, output_files["final_karaoke_cdg_zip"])
self.logger.info(f"Renamed CDG ZIP file from {expected_zip} to {output_files['final_karaoke_cdg_zip']}")
self.logger.info(f"Searching for CDG ZIP file. Expected: {expected_zip}")
if not os.path.isfile(output_files["final_karaoke_cdg_zip"]):
self.logger.error(f"Failed to find any CDG ZIP file. Listing directory contents:")
for file in os.listdir():
self.logger.error(f" - {file}")
raise Exception(f"Failed to create CDG ZIP file: {output_files['final_karaoke_cdg_zip']}")
if os.path.isfile(expected_zip):
self.logger.info(f"Found expected CDG ZIP file: {expected_zip}")
os.rename(expected_zip, output_files["final_karaoke_cdg_zip"])
self.logger.info(f"Renamed CDG ZIP file from {expected_zip} to {output_files['final_karaoke_cdg_zip']}")
self.logger.info(f"CDG ZIP file created: {output_files['final_karaoke_cdg_zip']}")
if not os.path.isfile(output_files["final_karaoke_cdg_zip"]):
self.logger.error(f"Failed to find any CDG ZIP file. Listing directory contents:")
for file in os.listdir():
self.logger.error(f" - {file}")
raise Exception(f"Failed to create CDG ZIP file: {output_files['final_karaoke_cdg_zip']}")
# Extract the CDG ZIP file
self.logger.info(f"Extracting CDG ZIP file: {output_files['final_karaoke_cdg_zip']}")
with zipfile.ZipFile(output_files["final_karaoke_cdg_zip"], "r") as zip_ref:
zip_ref.extractall()
self.logger.info(f"CDG ZIP file created: {output_files['final_karaoke_cdg_zip']}")
if os.path.isfile(output_files["karaoke_mp3"]):
self.logger.info(f"Found extracted MP3 file: {output_files['karaoke_mp3']}")
else:
self.logger.error("Failed to find extracted MP3 file")
raise Exception("Failed to extract MP3 file from CDG ZIP")
# Extract the CDG ZIP file
self.logger.info(f"Extracting CDG ZIP file: {output_files['final_karaoke_cdg_zip']}")
with zipfile.ZipFile(output_files["final_karaoke_cdg_zip"], "r") as zip_ref:
zip_ref.extractall()
if os.path.isfile(output_files["karaoke_mp3"]):
self.logger.info(f"Found extracted MP3 file: {output_files['karaoke_mp3']}")
else:
self.logger.error("Failed to find extracted MP3 file")
raise Exception("Failed to extract MP3 file from CDG ZIP")
def create_txt_zip_file(self, input_files, output_files):
self.logger.info(f"Creating TXT ZIP file...")
@@ -663,26 +791,17 @@ class KaraokeFinalise:
self.logger.info(f"TXT ZIP file created: {output_files['final_karaoke_txt_zip']}")
def encode_720p_version(self, input_file, output_file):
ffmpeg_command = (
f'{self.ffmpeg_base_command} -i "{input_file}" '
f'-c:v libx264 -vf "scale=1280:720" -b:v 200k -preset medium -tune animation '
f'-c:a copy "{output_file}"'
)
self.execute_command(ffmpeg_command, "Encoding 720p version of the final video")
def move_files_to_brand_code_folder(self, brand_code, artist, title, output_files):
self.logger.info(f"Moving files to new brand-prefixed directory...")
self.new_brand_code_dir = f"{brand_code} - {artist} - {title}"
self.new_brand_code_dir_path = os.path.join(self.organised_dir, self.new_brand_code_dir)
self.prompt_user_confirmation_or_raise_exception(
f"Move files to new brand-prefixed directory {self.new_brand_code_dir_path} and delete current dir?",
"Refusing to move files without user confirmation of move.",
allow_empty=True,
)
# self.prompt_user_confirmation_or_raise_exception(
# f"Move files to new brand-prefixed directory {self.new_brand_code_dir_path} and delete current dir?",
# "Refusing to move files without user confirmation of move.",
# allow_empty=True,
# )
orig_dir = os.getcwd()
os.chdir(os.path.dirname(orig_dir))
@@ -728,8 +847,8 @@ class KaraokeFinalise:
f"DRY RUN: Would copy final MP4, 720p MP4, and ZIP to {dest_mp4_file}, {dest_720p_mp4_file}, and {dest_zip_file}"
)
else:
shutil.copy2(output_files["final_karaoke_mp4"], dest_mp4_file)
shutil.copy2(output_files["final_karaoke_720p_mp4"], dest_720p_mp4_file)
shutil.copy2(output_files["final_karaoke_lossy_mp4"], dest_mp4_file) # Changed to use lossy MP4
shutil.copy2(output_files["final_karaoke_lossy_720p_mp4"], dest_720p_mp4_file)
shutil.copy2(output_files["final_karaoke_cdg_zip"], dest_zip_file)
self.logger.info(f"Copied final files to public share directory")
@@ -787,6 +906,19 @@ class KaraokeFinalise:
self.logger.error(f"Command output (stderr): {e.stderr}")
self.logger.error(f"Full exception: {e}")
def get_existing_brand_code(self):
"""Extract brand code from current directory name"""
current_dir = os.path.basename(os.getcwd())
if " - " not in current_dir:
raise Exception(f"Current directory '{current_dir}' does not match expected format 'BRAND-XXXX - Artist - Title'")
brand_code = current_dir.split(" - ")[0]
if not brand_code or "-" not in brand_code:
raise Exception(f"Could not extract valid brand code from directory name '{current_dir}'")
self.logger.info(f"Using existing brand code: {brand_code}")
return brand_code
def execute_optional_features(self, artist, title, base_name, input_files, output_files):
self.logger.info(f"Executing optional features...")
@@ -805,7 +937,16 @@ class KaraokeFinalise:
self.post_discord_notification()
if self.folder_organisation_enabled:
self.brand_code = self.get_next_brand_code()
if self.keep_brand_code:
self.brand_code = self.get_existing_brand_code()
self.new_brand_code_dir = os.path.basename(os.getcwd())
self.new_brand_code_dir_path = os.getcwd()
else:
self.brand_code = self.get_next_brand_code()
self.move_files_to_brand_code_folder(self.brand_code, artist, title, output_files)
# Update output file paths after moving
for key in output_files:
output_files[key] = os.path.join(self.new_brand_code_dir_path, os.path.basename(output_files[key]))
if self.public_share_copy_enabled:
self.copy_final_files_to_public_share_dirs(self.brand_code, base_name, output_files)
@@ -813,10 +954,88 @@ class KaraokeFinalise:
if self.public_share_rclone_enabled:
self.sync_public_share_dir_to_rclone_destination()
self.move_files_to_brand_code_folder(self.brand_code, artist, title, output_files)
self.generate_organised_folder_sharing_link()
def authenticate_gmail(self):
"""Authenticate and return a Gmail service object."""
creds = None
gmail_token_file = "/tmp/karaoke-finalise-gmail-token.pickle"
if os.path.exists(gmail_token_file):
with open(gmail_token_file, "rb") as token:
creds = pickle.load(token)
if not creds or not creds.valid:
if creds and creds.expired and creds.refresh_token:
creds.refresh(Request())
else:
flow = InstalledAppFlow.from_client_secrets_file(
self.youtube_client_secrets_file, ["https://www.googleapis.com/auth/gmail.compose"]
)
creds = flow.run_local_server(port=0)
with open(gmail_token_file, "wb") as token:
pickle.dump(creds, token)
return build("gmail", "v1", credentials=creds)
def draft_completion_email(self, artist, title, youtube_url, dropbox_url):
if not self.email_template_file:
self.logger.info("Email template file not provided, skipping email draft creation.")
return
with open(self.email_template_file, "r") as f:
template = f.read()
email_body = template.format(youtube_url=youtube_url, dropbox_url=dropbox_url)
subject = f"{self.brand_code}: {artist} - {title}"
if self.dry_run:
self.logger.info(f"DRY RUN: Would create email draft with subject: {subject}")
self.logger.info(f"DRY RUN: Email body:\n{email_body}")
else:
if not self.gmail_service:
self.gmail_service = self.authenticate_gmail()
message = MIMEText(email_body)
message["subject"] = subject
raw_message = base64.urlsafe_b64encode(message.as_bytes()).decode("utf-8")
draft = self.gmail_service.users().drafts().create(userId="me", body={"message": {"raw": raw_message}}).execute()
self.logger.info(f"Email draft created with ID: {draft['id']}")
def test_email_template(self):
if not self.email_template_file:
self.logger.error("Email template file not provided. Use --email_template_file to specify the file path.")
return
fake_artist = "Test Artist"
fake_title = "Test Song"
fake_youtube_url = "https://www.youtube.com/watch?v=dQw4w9WgXcQ"
fake_dropbox_url = "https://www.dropbox.com/sh/fake/folder/link"
fake_brand_code = "TEST-0001"
self.brand_code = fake_brand_code
self.draft_completion_email(fake_artist, fake_title, fake_youtube_url, fake_dropbox_url)
self.logger.info("Email template test complete. Check your Gmail drafts for the test email.")
def detect_best_aac_codec(self):
"""Detect the best available AAC codec (aac_at > libfdk_aac > aac)"""
self.logger.info("Detecting best available AAC codec...")
codec_check_command = f"{self.ffmpeg_base_command} -codecs"
result = os.popen(codec_check_command).read()
if "aac_at" in result:
self.logger.info("Using aac_at codec (best quality)")
return "aac_at"
elif "libfdk_aac" in result:
self.logger.info("Using libfdk_aac codec (good quality)")
return "libfdk_aac"
else:
self.logger.info("Using built-in aac codec (basic quality)")
return "aac"
def process(self):
if self.dry_run:
self.logger.warning("Dry run enabled. No actions will be performed.")
@@ -839,7 +1058,6 @@ class KaraokeFinalise:
self.create_txt_zip_file(input_files, output_files)
self.remux_and_encode_output_video_files(with_vocals_file, input_files, output_files)
self.encode_720p_version(output_files["final_karaoke_mp4"], output_files["final_karaoke_720p_mp4"])
self.execute_optional_features(artist, title, base_name, input_files, output_files)
@@ -847,9 +1065,11 @@ class KaraokeFinalise:
"artist": artist,
"title": title,
"video_with_vocals": output_files["with_vocals_mp4"],
"video_with_instrumental": output_files["karaoke_mov"],
"final_video": output_files["final_karaoke_mp4"],
"final_video_720p": output_files["final_karaoke_720p_mp4"],
"video_with_instrumental": output_files["karaoke_mp4"],
"final_video": output_files["final_karaoke_lossless_mp4"],
"final_video_mkv": output_files["final_karaoke_lossless_mkv"],
"final_video_lossy": output_files["final_karaoke_lossy_mp4"],
"final_video_720p": output_files["final_karaoke_lossy_720p_mp4"],
"youtube_url": self.youtube_url,
"brand_code": self.brand_code,
"new_brand_code_dir_path": self.new_brand_code_dir_path,
@@ -862,4 +1082,7 @@ class KaraokeFinalise:
if self.enable_txt:
result["final_karaoke_txt_zip"] = output_files["final_karaoke_txt_zip"]
if self.email_template_file:
self.draft_completion_email(artist, title, result["youtube_url"], result["brand_code_dir_sharing_link"])
return result
File diff suppressed because it is too large. Load diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
+103 -14
View File
@@ -4,6 +4,9 @@ import logging
import pkg_resources
import os
import sys
import json
import pyperclip
import time
from karaoke_prep.karaoke_finalise import KaraokeFinalise
@@ -16,7 +19,7 @@ def main():
parser = argparse.ArgumentParser(
description="Render, remux and join intermediate files to create final karaoke video, as the third stage after using karaoke-prep. Processes all (Karaoke).mov files in current directory.",
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=54),
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=62),
)
package_version = pkg_resources.get_distribution("karaoke-prep").version
@@ -107,6 +110,37 @@ def main():
help="Optional: Discord webhook URL to send notifications to. Example: --discord_webhook_url='https://discord.com/api/webhooks/1234567890/TOKEN/messages",
)
parser.add_argument(
"--email_template_file",
default=None,
help="Optional: File path to email template for drafting completion email. Example: --email_template_file='/path/to/email_template.txt'",
)
parser.add_argument(
"--test_email_template",
action="store_true",
help="Optional: Test the email template functionality with fake data. Example: --test_email_template",
)
parser.add_argument(
"--style_params_json",
default=None,
help="Optional: Path to JSON file containing CDG style configuration. Required if --enable_cdg is used. Example: --style_params_json='/path/to/cdg_styles.json'",
)
parser.add_argument(
"--keep-brand-code",
action="store_true",
help="Optional: Use existing brand code from current directory instead of generating new one (default: disabled). Example: --keep-brand-code",
)
parser.add_argument(
"-y",
"--yes",
action="store_true",
help="Optional: Run in non-interactive mode, assuming yes to all prompts (default: disabled). Example: -y",
)
args = parser.parse_args()
log_level = getattr(logging, args.log_level.upper())
@@ -114,6 +148,23 @@ def main():
logger.info(f"KaraokeFinalise CLI beginning initialisation...")
# Load CDG styles if CDG generation is enabled
cdg_styles = None
if args.enable_cdg:
if not args.style_params_json:
logger.error("CDG styles JSON file path (--style_params_json) is required when --enable_cdg is used")
sys.exit(1)
try:
with open(args.style_params_json, "r") as f:
style_params = json.loads(f.read())
cdg_styles = style_params["cdg"]
except FileNotFoundError:
logger.error(f"CDG styles configuration file not found: {args.style_params_json}")
sys.exit(1)
except json.JSONDecodeError as e:
logger.error(f"Invalid JSON in CDG styles configuration file: {e}")
sys.exit(1)
kfinalise = KaraokeFinalise(
log_formatter=log_formatter,
log_level=log_level,
@@ -130,34 +181,72 @@ def main():
youtube_description_file=args.youtube_description_file,
rclone_destination=args.rclone_destination,
discord_webhook_url=args.discord_webhook_url,
email_template_file=args.email_template_file,
cdg_styles=cdg_styles,
keep_brand_code=args.keep_brand_code,
non_interactive=args.yes,
)
try:
track = kfinalise.process()
except Exception as e:
logger.error(f"An error occurred during finalisation, see stack trace below: {str(e)}")
raise e
if args.test_email_template:
logger.info("Testing email template functionality...")
kfinalise.test_email_template()
else:
try:
track = kfinalise.process()
except Exception as e:
logger.error(f"An error occurred during finalisation, see stack trace below: {str(e)}")
raise e
logger.info(f"Karaoke finalisation processing complete! Output files:")
logger.info(f"")
logger.info(f"Track: {track['artist']} - {track['title']}")
logger.info(f"")
logger.info(f"Working Files:")
logger.info(f" Video With Vocals: {track['video_with_vocals']}")
logger.info(f" Video With Instrumental: {track['video_with_instrumental']}")
logger.info(f"")
logger.info(f"Final Videos:")
logger.info(f" Lossless 4K MP4 (PCM): {track['final_video']}")
logger.info(f" Lossless 4K MKV (FLAC): {track['final_video_mkv']}")
logger.info(f" Lossy 4K MP4 (AAC): {track['final_video_lossy']}")
logger.info(f" Lossy 720p MP4 (AAC): {track['final_video_720p']}")
if "final_karaoke_cdg_zip" in track or "final_karaoke_txt_zip" in track:
logger.info(f"")
logger.info(f"Karaoke Files:")
if "final_karaoke_cdg_zip" in track:
logger.info(f" Final CDG+MP3 ZIP: {track['final_karaoke_cdg_zip']}")
logger.info(f" CDG+MP3 ZIP: {track['final_karaoke_cdg_zip']}")
if "final_karaoke_txt_zip" in track:
logger.info(f" Final TXT+MP3 ZIP: {track['final_karaoke_txt_zip']}")
logger.info(f" TXT+MP3 ZIP: {track['final_karaoke_txt_zip']}")
logger.info(f" Final Video with Title: {track['final_video']}")
logger.info(f" Final Video 720p: {track['final_video_720p']}")
if track["brand_code"]:
logger.info(f"")
logger.info(f"Organization:")
logger.info(f" Brand Code: {track['brand_code']}")
logger.info(f" New Directory: {track['new_brand_code_dir_path']}")
logger.info(f" Brand Code: {track['brand_code']}")
logger.info(f" New Brand Code Directory: {track['new_brand_code_dir_path']}")
if track["youtube_url"] or track["brand_code_dir_sharing_link"]:
logger.info(f"")
logger.info(f"Sharing:")
logger.info(f" YouTube URL: {track['youtube_url']}")
logger.info(f" Folder Sharing Link: {track['brand_code_dir_sharing_link']}")
if track["brand_code_dir_sharing_link"]:
logger.info(f" Folder Link: {track['brand_code_dir_sharing_link']}")
try:
time.sleep(1) # Brief pause between clipboard operations
pyperclip.copy(track["brand_code_dir_sharing_link"])
logger.info(f" (Folder link copied to clipboard)")
except Exception as e:
logger.warning(f" Failed to copy folder link to clipboard: {str(e)}")
if track["youtube_url"]:
logger.info(f" YouTube URL: {track['youtube_url']}")
try:
pyperclip.copy(track["youtube_url"])
logger.info(f" (YouTube URL copied to clipboard)")
except Exception as e:
logger.warning(f" Failed to copy YouTube URL to clipboard: {str(e)}")
if __name__ == "__main__":
+90 -241
View File
@@ -4,6 +4,8 @@ import logging
import pkg_resources
import tempfile
import os
import json
import sys
from karaoke_prep import KaraokePrep
@@ -29,6 +31,7 @@ def main():
formatter_class=lambda prog: argparse.RawTextHelpFormatter(prog, max_help_position=54),
)
# Basic information
parser.add_argument(
"args",
nargs="*",
@@ -38,36 +41,68 @@ def main():
package_version = pkg_resources.get_distribution("karaoke-prep").version
parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {package_version}")
# Logging & Debugging
parser.add_argument(
"--log_level",
default="info",
help="Optional: logging level, e.g. info, debug, warning (default: %(default)s). Example: --log_level=debug",
)
parser.add_argument(
"--filename_pattern",
help="Required if processing a folder: Python regex pattern to extract track names from filenames. Must contain a named group 'title'. Example: --filename_pattern='(?P<index>\\d+) - (?P<title>.+).mp3'",
)
parser.add_argument(
"--dry_run",
action="store_true",
help="Optional: perform a dry run without making any changes (default: %(default)s). Example: --dry_run=true",
)
parser.add_argument(
"--render_bounding_boxes",
action="store_true",
help="Optional: render bounding boxes around text regions for debugging (default: %(default)s). Example: --render_bounding_boxes",
)
# Input/Output Configuration
parser.add_argument(
"--filename_pattern",
help="Required if processing a folder: Python regex pattern to extract track names from filenames. Must contain a named group 'title'. Example: --filename_pattern='(?P<index>\\d+) - (?P<title>.+).mp3'",
)
parser.add_argument(
"--output_dir",
default=".",
help="Optional: directory to write output files (default: <current dir>). Example: --output_dir=/app/karaoke",
)
parser.add_argument(
"--no_track_subfolders",
action="store_false",
help="Optional: do NOT create a named subfolder for each track. Example: --no_track_subfolders",
)
parser.add_argument(
"--lossless_output_format",
default="FLAC",
help="Optional: lossless output format for separated audio (default: FLAC). Example: --lossless_output_format=WAV",
)
parser.add_argument(
"--output_png",
type=lambda x: (str(x).lower() == "true"),
default=True,
help="Optional: output PNG format for title and end images (default: %(default)s). Example: --output_png=False",
)
parser.add_argument(
"--output_jpg",
type=lambda x: (str(x).lower() == "true"),
default=True,
help="Optional: output JPG format for title and end images (default: %(default)s). Example: --output_jpg=False",
)
# Audio Processing Configuration
parser.add_argument(
"--clean_instrumental_model",
default="model_bs_roformer_ep_317_sdr_12.9755.ckpt",
help="Optional: Model for clean instrumental separation (default: %(default)s).",
)
parser.add_argument(
"--backing_vocals_models",
nargs="+",
default=["mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt", "UVR-BVE-4B_SN-44100-1.pth"],
default=["mel_band_roformer_karaoke_aufr33_viperx_sdr_10.1956.ckpt"],
help="Optional: List of models for backing vocals separation (default: %(default)s).",
)
parser.add_argument(
"--other_stems_models",
nargs="+",
@@ -87,38 +122,16 @@ def main():
default=default_model_dir,
help="Optional: model files directory (default: %(default)s). Example: --model_file_dir=/app/models",
)
parser.add_argument(
"--output_dir",
default=".",
help="Optional: directory to write output files (default: <current dir>). Example: --output_dir=/app/karaoke",
"--existing_instrumental",
help="Optional: Path to an existing instrumental audio file. If provided, audio separation will be skipped.",
)
parser.add_argument(
"--lossless_output_format",
default="FLAC",
help="Optional: lossless output format for separated audio (default: FLAC). Example: --lossless_output_format=WAV",
)
parser.add_argument(
"--use_cuda",
action="store_true",
help="Optional: use Nvidia GPU with CUDA for separation (default: %(default)s). Example: --use_cuda=true",
)
parser.add_argument(
"--use_coreml",
action="store_true",
help="Optional: use Apple Silicon GPU with CoreML for separation (default: %(default)s). Example: --use_coreml=true",
)
parser.add_argument(
"--denoise",
type=lambda x: (str(x).lower() == "true"),
default=True,
help="Optional: enable or disable denoising during separation (default: %(default)s). Example: --denoise=False",
)
parser.add_argument(
"--normalize",
type=lambda x: (str(x).lower() == "true"),
@@ -126,193 +139,43 @@ def main():
help="Optional: enable or disable normalization during separation (default: %(default)s). Example: --normalize=False",
)
# Hardware Acceleration
parser.add_argument(
"--no_track_subfolders",
action="store_false",
help="Optional: do NOT create a named subfolder for each track. Example: --no_track_subfolders",
"--use_cuda",
action="store_true",
help="Optional: use Nvidia GPU with CUDA for separation (default: %(default)s). Example: --use_cuda=true",
)
parser.add_argument(
"--intro_background_color",
default="#000000",
help="Optional: Background color for intro video (default: black). Example: --intro_background_color=#123456",
)
parser.add_argument(
"--intro_background_image",
help="Optional: Path to background image for intro video. Overrides background color if provided. Example: --intro_background_image=path/to/image.jpg",
)
parser.add_argument(
"--intro_font",
default="Montserrat-Bold.ttf",
help="Optional: Font file for intro video (default: Montserrat-Bold.ttf). Example: --intro_font=AvenirNext-Bold.ttf",
)
parser.add_argument(
"--intro_artist_color",
default="#ffdf6b",
help="Optional: Font color for intro video artist text (default: #ffdf6b). Example: --intro_artist_color=#123456",
)
parser.add_argument(
"--intro_title_color",
default="#ffffff",
help="Optional: Font color for intro video title text (default: #ffffff). Example: --intro_title_color=#123456",
)
parser.add_argument(
"--existing_instrumental",
help="Optional: Path to an existing instrumental audio file. If provided, audio separation will be skipped.",
)
parser.add_argument(
"--existing_title_image",
help="Optional: Path to an existing title image file. If provided, title image generation will be skipped.",
)
parser.add_argument(
"--end_background_color",
default="#000000",
help="Optional: Background color for end screen video (default: black). Example: --end_background_color=#123456",
)
parser.add_argument(
"--end_background_image",
help="Optional: Path to background image for end screen video. Overrides background color if provided. Example: --end_background_image=path/to/image.jpg",
)
parser.add_argument(
"--end_extra_text",
default="THANK YOU FOR SINGING!",
help="Optional: Extra text to display on the end screen video. Example: --end_extra_text='THANK YOU FOR WATCHING!'",
)
parser.add_argument(
"--end_font",
default="Montserrat-Bold.ttf",
help="Optional: Font file for end screen video (default: Montserrat-Bold.ttf). Example: --end_font=AvenirNext-Bold.ttf",
)
parser.add_argument(
"--end_extra_text_color",
default="#ff7acc",
help="Optional: Font color for end screen video text (default: #ffffff). Example: --end_extra_text_color=#123456",
)
parser.add_argument(
"--end_artist_color",
default="#ffdf6b",
help="Optional: Font color for end screen video artist text (default: #ffdf6b). Example: --end_artist_color=#123456",
)
parser.add_argument(
"--end_title_color",
default="#ffffff",
help="Optional: Font color for end screen video title text (default: #ffffff). Example: --end_title_color=#123456",
)
parser.add_argument(
"--existing_end_image",
help="Optional: Path to an existing end screen image file. If provided, end screen image generation will be skipped.",
)
parser.add_argument(
"--title_video_duration",
type=int,
default=5,
help="Optional: duration of the title video in seconds (default: 5). Example: --title_video_duration=10",
)
parser.add_argument(
"--end_video_duration",
type=int,
default=5,
help="Optional: duration of the end video in seconds (default: 5). Example: --end_video_duration=10",
)
parser.add_argument(
"--title_initial_font_size",
type=int,
default=500,
help="Optional: Initial font size for title video (default: 500). Example: --title_initial_font_size=600",
)
parser.add_argument(
"--title_top_padding",
type=int,
default=950,
help="Optional: Top padding for title video (default: 950). Example: --title_top_padding=1000",
)
parser.add_argument(
"--title_title_padding",
type=int,
default=400,
help="Optional: Title padding for title video (default: 400). Example: --title_title_padding=450",
)
parser.add_argument(
"--title_artist_padding",
type=int,
default=700,
help="Optional: Artist padding for title video (default: 700). Example: --title_artist_padding=750",
)
parser.add_argument(
"--title_fixed_gap",
type=int,
default=150,
help="Optional: Fixed gap for title video (default: 150). Example: --title_fixed_gap=200",
)
parser.add_argument(
"--end_initial_font_size",
type=int,
default=500,
help="Optional: Initial font size for end video (default: 500). Example: --end_initial_font_size=600",
)
parser.add_argument(
"--end_top_padding",
type=int,
default=950,
help="Optional: Top padding for end video (default: 950). Example: --end_top_padding=1000",
)
parser.add_argument(
"--end_title_padding",
type=int,
default=400,
help="Optional: Title padding for end video (default: 400). Example: --end_title_padding=450",
)
parser.add_argument(
"--end_artist_padding",
type=int,
default=700,
help="Optional: Artist padding for end video (default: 700). Example: --end_artist_padding=750",
)
parser.add_argument(
"--end_extra_text_padding",
type=int,
default=300,
help="Optional: Extra text padding for end video (default: 600). Example: --end_extra_text_padding=650",
)
parser.add_argument(
"--end_fixed_gap",
type=int,
default=150,
help="Optional: Fixed gap for end video (default: 150). Example: --end_fixed_gap=200",
"--use_coreml",
action="store_true",
help="Optional: use Apple Silicon GPU with CoreML for separation (default: %(default)s). Example: --use_coreml=true",
)
# Lyrics Configuration
parser.add_argument(
"--lyrics_artist",
help="Optional: Override the artist name used for lyrics search. Example: --lyrics_artist='The Beatles'",
)
parser.add_argument(
"--lyrics_title",
help="Optional: Override the song title used for lyrics search. Example: --lyrics_title='Hey Jude'",
)
parser.add_argument(
"--skip_lyrics",
action="store_true",
help="Optional: Skip fetching and processing lyrics. Example: --skip_lyrics",
)
parser.add_argument(
"--skip_transcription",
action="store_true",
help="Optional: Skip audio transcription but still attempt to fetch lyrics from Spotify/Genius. Example: --skip_transcription",
)
# Style Configuration
parser.add_argument(
"--style_params_json",
help="Optional: Path to JSON file containing style configuration for intro/end videos. Example: --style_params_json='/path/to/style_params.json'",
)
args = parser.parse_args()
@@ -360,63 +223,43 @@ def main():
log_level = getattr(logging, args.log_level.upper())
logger.setLevel(log_level)
if args.existing_instrumental:
args.clean_instrumental_model = None
args.backing_vocals_models = []
args.other_stems_models = []
logger.info(f"KaraokePrep beginning with input_media: {input_media} artist: {artist} and title: {title}")
kprep = KaraokePrep(
# Basic inputs
artist=artist,
title=title,
input_media=input_media,
filename_pattern=filename_pattern,
# Logging & Debugging
dry_run=args.dry_run,
log_formatter=log_formatter,
log_level=log_level,
render_bounding_boxes=args.render_bounding_boxes,
# Input/Output Configuration
filename_pattern=filename_pattern,
output_dir=args.output_dir,
create_track_subfolders=args.no_track_subfolders,
lossless_output_format=args.lossless_output_format,
output_png=args.output_png,
output_jpg=args.output_jpg,
# Audio Processing Configuration
existing_instrumental=args.existing_instrumental,
clean_instrumental_model=args.clean_instrumental_model,
backing_vocals_models=args.backing_vocals_models,
other_stems_models=args.other_stems_models,
model_file_dir=args.model_file_dir,
output_dir=args.output_dir,
lossless_output_format=args.lossless_output_format,
denoise_enabled=args.denoise,
normalization_enabled=args.normalize,
# Hardware Acceleration
use_cuda=args.use_cuda,
use_coreml=args.use_coreml,
normalization_enabled=args.normalize,
denoise_enabled=args.denoise,
create_track_subfolders=args.no_track_subfolders,
existing_instrumental=args.existing_instrumental,
existing_title_image=args.existing_title_image,
existing_end_image=args.existing_end_image,
title_video_duration=args.title_video_duration,
intro_background_color=args.intro_background_color,
intro_background_image=args.intro_background_image,
intro_font=args.intro_font,
intro_artist_color=args.intro_artist_color,
intro_title_color=args.intro_title_color,
title_initial_font_size=args.title_initial_font_size,
title_top_padding=args.title_top_padding,
title_title_padding=args.title_title_padding,
title_artist_padding=args.title_artist_padding,
title_fixed_gap=args.title_fixed_gap,
end_video_duration=args.end_video_duration,
end_extra_text=args.end_extra_text,
end_background_color=args.end_background_color,
end_background_image=args.end_background_image,
end_font=args.end_font,
end_extra_text_color=args.end_extra_text_color,
end_artist_color=args.end_artist_color,
end_title_color=args.end_title_color,
end_initial_font_size=args.end_initial_font_size,
end_top_padding=args.end_top_padding,
end_title_padding=args.end_title_padding,
end_artist_padding=args.end_artist_padding,
end_extra_text_padding=args.end_extra_text_padding,
end_fixed_gap=args.end_fixed_gap,
# Lyrics Configuration
lyrics_artist=args.lyrics_artist,
lyrics_title=args.lyrics_title,
skip_lyrics=args.skip_lyrics,
skip_transcription=args.skip_transcription,
# Style Configuration
style_params_json=args.style_params_json,
)
tracks = kprep.process()
@@ -453,6 +296,12 @@ def main():
for stem_type, file_path in stems.items():
logger.info(f" {stem_type.capitalize()}: {file_path}")
# Combined Instrumentals
logger.info(f" Combined Instrumentals:")
for model, file_path in track["separated_audio"]["combined_instrumentals"].items():
logger.info(f" Model: {model}")
logger.info(f" Combined Instrumental: {file_path}")
if __name__ == "__main__":
main()
Generated
+2284 -1382
View File
File diff suppressed because it is too large. Load diff
+3 -5
View File
@@ -1,6 +1,6 @@
[tool.poetry]
name = "karaoke-prep"
version = "0.28.0"
version = "0.38.2"
description = "Prepare for karaoke video creation, by downloading audio and lyrics for a specified song or playlist from youtube and separating audio stems. After syncing, finalise the video with a title screen!"
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
license = "MIT"
@@ -12,7 +12,7 @@ documentation = "https://github.com/karaokenerds/karaoke-prep/blob/main/README.m
[tool.poetry.dependencies]
python = ">=3.10,<3.13"
torch = ">=2.3,<2.5"
torch = "<2.5"
requests = ">=2"
beautifulsoup4 = ">=4"
yt-dlp = "*"
@@ -24,14 +24,12 @@ google-api-python-client = "*"
google-auth = "*"
google-auth-oauthlib = "*"
google-auth-httplib2 = "*"
pyperclip = ">=1.8"
thefuzz = ">=0.22"
numpy = "^1"
audio-separator = { version = ">=0.21.0", extras = ["cpu"] }
lyrics-converter = ">=0.2.1"
lyrics-transcriber = ">=0.18"
lyrics-transcriber = ">=0.34"
kbputils = "^0.0.16"
karaoke-lyrics-processor = ">=0.4.0"
attrs = ">=24.2.0"
cattrs = ">=24.1.2"
toml = ">=0.10"
+714
View File
@@ -0,0 +1,714 @@
[
["This Is Me Smiling", "Prettier"],
["Ленинград", "Алкаш"],
["Cher", "Apples Don't Fall Far From The Tree"],
["The Hush Sound", "Don't Wake Me Up"],
["ABBA", "I Am The City"],
["ABBA", "Under Attack"],
["The Hush Sound", "A Dark Congregation"],
["The Hush Sound", "As You Cry"],
["The Hush Sound", "Boys Are Too Refined"],
["The Hush Sound", "Break the Sky"],
["The Hush Sound", "Carry Me Home"],
["The Hush Sound", "City Traffic Puzzle"],
["The Hush Sound", "Crawling Towards The Sun"],
["The Hush Sound", "Echo"],
["The Hush Sound", "Eileen"],
["The Hush Sound", "Honey"],
["The Hush Sound", "Hospital Bed Crawl"],
["The Hush Sound", "Hourglass"],
["The Hush Sound", "Hurricane"],
["The Hush Sound", "Intro"],
["The Hush Sound", "Lions Roar"],
["The Hush Sound", "Love You Much Better"],
["The Hush Sound", "Magnolia"],
["The Hush Sound", "Medicine Man"],
["The Hush Sound", "Molasses"],
["The Hush Sound", "Momentum"],
["The Hush Sound", "My Apologies"],
["The Hush Sound", "Not Your Concern"],
["The Hush Sound", "Out Through The Curtain"],
["The Hush Sound", "Sweet Tangerine"],
["The Hush Sound", "That's Okay"],
["The Hush Sound", "The Artist"],
["The Hush Sound", "The Market"],
["The Hush Sound", "Tides Change"],
["The Hush Sound", "Unsafe Safe"],
["The Hush Sound", "We Intertwined"],
["The Hush Sound", "Weeping Willow"],
["The Hush Sound", "Where We Went Wrong"],
["The Hush Sound", "Wine Red"],
["The Hush Sound", "You Are The Moon"],
["The Hush Sound", "Lighthouse"],
["Allie X", "GLAM!"],
["Lemaitre", "Rocket Girl (feat. Betty Who)"],
["Just Jack", "253"],
["Just Jack", "All Night Cinema"],
["Just Jack", "Astronaut"],
["Just Jack", "Blood"],
["Just Jack", "Disco Friends"],
["Just Jack", "Doctor Doctor"],
["Just Jack", "Embers"],
["Just Jack", "Glory Days"],
["Just Jack", "Goth In The Disco"],
["Just Jack", "Hold On"],
["Just Jack", "I Talk Too Much"],
["Just Jack", "Life Stories"],
["Just Jack", "Lo And Behold"],
["Just Jack", "Lost"],
["Just Jack", "Mourning Morning"],
["Just Jack", "No Time"],
["Just Jack", "So Wrong"],
["Just Jack", "Spectacular Failures"],
["Just Jack", "Starz in Their Eyes"],
["Just Jack", "Symphony of Sirens"],
["Just Jack", "The Day I Died"],
["Just Jack", "Writers Block"],
[
"Los Campesinos!",
"This Is How You Spell \"HAHAHA, We Destroyed the Hopes and Dreams of a Generation of Faux-Romantics\""
],
["Los Campesinos!", "2007, The Year Punk Broke (My Heart)"],
["Los Campesinos!", "And We Exhale and Roll Our Eyes in Unison"],
["Los Campesinos!", "Broken Heartbeats Sounds Like Breakbeats"],
["Los Campesinos!", "Death to Los Campesinos!"],
["Los Campesinos!", "Don't Tell Me to Do the Math(s)"],
["Los Campesinos!", "Drop It Doe Eyes"],
["Los Campesinos!", "Knee Deep At ATP"],
["Los Campesinos!", "My Year In Lists"],
["Los Campesinos!", "Sweet Dreams, Sweet Cheeks"],
["Los Campesinos!", "We Are All Accelerated Readers"],
["Los Campesinos!", "You! Me! Dancing!"],
["Mew", "156"],
["Mew", "Am I Wry? No"],
["Mew", "Behind the Drapes"],
["Mew", "Comforting Sounds"],
["Mew", "Eight Flew Over, One was Destroyed"],
["Mew", "Her Voice is Beyond Her Years"],
["Mew", "She Came Home for Christmas"],
["Mew", "She Spider"],
["Mew", "Snow Brigade"],
["Mew", "Symmetry"],
["of Montreal", "Gronlandic Edit"],
["Idlewild", "(I Am) What I Am Not"],
["Idlewild", "A Modern Way of Letting Go"],
["Idlewild", "Actually It's Darkness"],
["Idlewild", "American English"],
["Idlewild", "Century After Century"],
["Idlewild", "I Don't Have The Map"],
["Idlewild", "I Never Wanted"],
["Idlewild", "Idea Track"],
["Idlewild", "In Remote Part , Scottish Fiction"],
["Idlewild", "Let Me Sleep (Next To The Mirror)"],
["Idlewild", "Listen To What You've Got"],
["Idlewild", "Little Discourage"],
["Idlewild", "Live in a Hiding Place"],
["Idlewild", "Mistake Pageant"],
["Idlewild", "Out of Routine"],
["Idlewild", "Quiet Crown"],
["Idlewild", "Roseability"],
["Idlewild", "Rusty"],
["Idlewild", "Stay the Same"],
["Idlewild", "Tell Me Ten Words"],
["Idlewild", "The Bronze Medal"],
["Idlewild", "These Wooden Ideas"],
["Idlewild", "You Held the World in Your Arms"],
["Los Campesinos!", "A Heat Rash in the Shape of the Show Me State"],
["Los Campesinos!", "All Your Kayfabe Friends"],
["Los Campesinos!", "Coda A Burn Scar in the Shape of the Sooner State"],
["Los Campesinos!", "Documented Minor Emotional Breakdown #1"],
["Los Campesinos!", "Heart Swells:100-1"],
["Los Campesinos!", "Heart Swells / Pacific Daylight Time"],
["Los Campesinos!", "I Just Sighed, I Just Signed, Just So You Know"],
["Los Campesinos!", "I Warned You, Do Not Make an Enemy of Me"],
["Los Campesinos!", "In Medias Res"],
[
"Los Campesinos!",
"It's Never That Easy Though, Is It (Song For The Other Kurt)"
],
["Los Campesinos!", "Miserabilia"],
["Los Campesinos!", "Plan A"],
["Los Campesinos!", "Romance is Boring"],
["Los Campesinos!", "Straight in at 101"],
["Los Campesinos!", "The End Of The Asterisk"],
["Los Campesinos!", "The Sea is a Good Place to Think of the Future"],
["Los Campesinos!", "There Are Listed Buildings"],
["Los Campesinos!", "This is a Flag, There is No Wind"],
["Los Campesinos!", "Ways To Make It Through The Wall"],
["Los Campesinos!", "We Are Beautiful, We Are Doomed"],
["Los Campesinos!", "We've Got Your Back"],
["Los Campesinos!", "Who Fell Asleep In"],
["Los Campesinos!", "You'll Need Those Fingers For Crossing"],
["Miracles of Modern Science", "Bossa Supernova"],
["Miracles of Modern Science", "Eating Me Alive"],
["Miracles of Modern Science", "Friend Of The Animals"],
["Miracles of Modern Science", "I Found Space"],
["Miracles of Modern Science", "Luminol"],
["Miracles of Modern Science", "MOMS AWAY!"],
["Miracles of Modern Science", "Quantum Of Solace"],
["Miracles of Modern Science", "Secret Track"],
["Miracles of Modern Science", "Space Chopper"],
["Miracles of Modern Science", "Strangerous"],
["Miracles of Modern Science", "Tensity"],
["Miracles of Modern Science", "The Moon & Australia"],
["Nia Archives", "(Over)Thinking"],
["Nia Archives", "18 & Over"],
["Nia Archives", "Crossroads"],
["Nia Archives", "Don't Kid Urself"],
["Nia Archives", "Gud Gudbyez"],
["Nia Archives", "Headz Gone West"],
["Nia Archives", "Luv Like"],
["Nia Archives", "Part Of Me"],
["Nia Archives", "Sober Feels"],
["This Is Me Smiling", "A Better Way to Fall in Love"],
["This Is Me Smiling", "Alive in the Chase"],
["This Is Me Smiling", "Ephemera"],
["This Is Me Smiling", "Feelin' the Time Pass By"],
["This Is Me Smiling", "For When You Don't Hear It Right"],
["This Is Me Smiling", "Goodbye to Each New Day"],
["This Is Me Smiling", "Matter to Matter"],
["This Is Me Smiling", "Mixin' Up Adjectives"],
["This Is Me Smiling", "Say What You're Gonna Say"],
["This Is Me Smiling", "So Excited to Sleep"],
["This Is Me Smiling", "Up in All Directions"],
["Bug Hunter", "Dear McCracken"],
["Ken Ashcorp", "Burgz"],
["Ken Ashcorp", "Absolute Territory"],
["Ken Ashcorp", "I'm Your Slave"],
["Mew", "A Dark Design"],
["Mew", "An Envoy To The Open Fields"],
["Mew", "Apocalypso"],
["Mew", "Chinaberry Tree"],
["Mew", "Fox Cub"],
["Mew", "Louise Louisa"],
["Mew", "Saviours Of Jazz Ballet"],
["Mew", "Special"],
["Mew", "The Seething Rain Weeps For You"],
["Mew", "The Zookeeper's Boy"],
["Mew", "White Lips Kissed"],
["Mew", "Why Are You Looking Grave"],
["Get Cape. Wear Cape. Fly", "An Oak Tree"],
["Get Cape. Wear Cape. Fly", "Call Me Ishmael"],
["Get Cape. Wear Cape. Fly", "Get Cape. Wear Cape. Fly"],
["Get Cape. Wear Cape. Fly", "Glasshouses"],
["Get Cape. Wear Cape. Fly", "I-Spy"],
[
"Get Cape. Wear Cape. Fly",
"If I Had £1 For Every Stale Song Title I'd Be 30 Short Of Getting Out Of This Mess"
],
["Get Cape. Wear Cape. Fly", "Once More With Feeling"],
[
"Get Cape. Wear Cape. Fly",
"The Chronicles Of A Bohemian Teenager (Part Two)"
],
[
"Get Cape. Wear Cape. Fly",
"The Chronicles Of A Bohemian Teenager (Part One)"
],
["Get Cape. Wear Cape. Fly", "The Lighthousekeeper"],
["Get Cape. Wear Cape. Fly", "War Of The Worlds"],
["Get Cape. Wear Cape. Fly", "Whitewash Is Brainwash"],
["Hi I'm Case", "Smoke Damage (Youtube version)"],
["Ken Ashcorp", "Wear"],
["Hi I'm Case", "Smoke Damage (Spotify version)"],
["Neil Diamond", "The Look Of Love"],
["Amy Winehouse", "Valerie (Short Version)"],
["Anastacia", "I'm Outta Love (Short Version)"],
["Calum Scott", "Dancing On My Own (Short Version)"],
["Ed Sheeran", "Shivers (Short Version)"],
["Eminem", "Without Me (Short Version)"],
["Gnarls Barkley", "Crazy (Short Version)"],
["Jess Glynne", "Hold My Hand (Short Version)"],
["Kenny Loggins", "Footloose (Short Version)"],
["Kings Of Leon", "Sex on Fire (Short Version)"],
["Lady Gaga", "Born This Way (Short Version)"],
["Miley Cyrus", "Jolene (Short Version)"],
["Miley Cyrus", "Wrecking Ball (Short Version)"],
["Robbie Williams", "Angels (Short Version)"],
["Shakira", "Whenever, Wherever (Short Version)"],
["Shania Twain", "Man! I Feel Like A Woman (Short Version)"],
["Shirley Bassey", "Big Spender (Short Version)"],
["The Killers", "Mr. Brightside (Short Version)"],
["The Pussycat Dolls", "Sway (Short Version)"],
["Twenty One Pilots", "Stressed Out (Short Version)"],
["Wheatus", "Teenage Dirtbag (Short Version)"],
["Christina Stürmer", "Nie Genug"],
["James Brown", "It's a Man's World (Short Version)"],
["Jerry Lee Lewis", "Great Balls Of Fire (Short Version)"],
["Melanie Martinez", "Toxic (Short Version)"],
["Melissa Etheridge", "Bring Me Some Water (Short Version)"],
["Queen", "Crazy Little Thing Called Love (Short Version)"],
["Tina Turner", "Proud Mary (Short Version)"],
["Tina Turner", "The Best (Short Version)"],
["Tom Jones", "Help Yourself (Short Version)"],
["Tom Jones", "Sex Bomb (Short Version)"],
["Andreas Gabalier", "Hulapalu (Short Version)"],
["Christina Stürmer", "Nie Genug (Short Version)"],
["Die Draufgänger", "Cordula Grün (Short Version)"],
["Jimi Jamison", "I'm Always Here (Short Version)"],
["Jürgen Drews", "Ein Bett im Kornfeld"],
["Jürgen Drews", "Ein Bett im Kornfeld (Short Version)"],
["STS", "Kalt Und Kälter (Short Version)"],
["STS", "Kalt Und Kälter"],
["Udo Jürgens", "Aber bitte mit Sahne"],
["Udo Jürgens", "Aber bitte mit Sahne (Short Version)"],
["Bryan Adams", "Summer of '69 (Short Version)"],
["Dylan Emmet", "Lose This"],
["Loosey LaDuca", "Let Loose"],
["Against Me", "People Who Died"],
["Eleven Hundred Springs", "Thunderbird Will Do Just Fine"],
["Etherwood", "Begin By Letting Go"],
["Foy Vance", "She Burns"],
["Frightened Rabbit", "Late March Death March"],
["George Barnett", "Stone Cold Classic"],
["Get Cape. Wear Cape. Fly", "Better Things (ft. Kate Nash)"],
["Get Cape. Wear Cape. Fly", "Could've Seen It All"],
["Get Cape. Wear Cape. Fly", "Find The Time"],
["Get Cape. Wear Cape. Fly", "I Could Build You A Tower"],
["Get Cape. Wear Cape. Fly", "Keep Singing Out"],
["Get Cape. Wear Cape. Fly", "Let The Journey Begin"],
["Get Cape. Wear Cape. Fly", "Moving Forward"],
["Get Cape. Wear Cape. Fly", "Postcards From Catalunya"],
[
"Get Cape. Wear Cape. Fly",
"The Children Are (The Consumers Of) The Future"
],
["Get Cape. Wear Cape. Fly", "This Could Be All"],
["Get Cape. Wear Cape. Fly", "Waiting For The Monster To Drown"],
["Get Cape. Wear Cape. Fly", "Window Of Your Mind"],
["Get Cape. Wear Cape. Fly", "Young And Lovestruck"],
["K-Os", "The Rain"],
["Nothing But Thieves", "Pop The Balloon"],
["Robbie Basho", "Blue Crystal Fire"],
["Smino", "Lee and Lovie"],
["The Skints", "Murderer"],
["Xan Griffin", "Capricorn (ft. WOLFE)"],
["Pulp", "Cocaine Socialism"],
["Random Hand", "Play Some Ska"],
["Sexyy Red, Nicki Minaj & Tay Keith", "Pound Town 2"],
["Tori Amos", "Liquid Diamonds"],
["Frightened Rabbit", "Music Now"],
["Frightened Rabbit", "Housing (out)"],
["Frightened Rabbit", "The Modern Leper"],
["Frightened Rabbit", "A Lick Of Paint"],
["Frightened Rabbit", "The Greys"],
["Frightened Rabbit", "Head Rolls Off"],
["Frightened Rabbit", "Backyard Skulls"],
["Frightened Rabbit", "The Wreck"],
["Frightened Rabbit", "My Backwards Walk"],
["Frightened Rabbit", "Be Less Rude"],
["Frightened Rabbit", "Die Like A Rich Boy"],
["Frightened Rabbit", "State Hospital"],
["Frightened Rabbit", "Skip the Youth"],
["Frightened Rabbit", "Yes, I Would"],
["Frightened Rabbit", "Floating in the Forth"],
["Frightened Rabbit", "Nitrous Gas"],
["Frightened Rabbit", "Break"],
["Frightened Rabbit", "Things"],
["Frightened Rabbit", "Nothing Like You"],
["Frightened Rabbit", "Good Arms vs Bad Arms"],
["Frightened Rabbit", "Foot Shooter"],
["Frightened Rabbit", "The Twist"],
["Frightened Rabbit", "The Loneliness and the Scream"],
["Frightened Rabbit", "Swim Until You Can't See Land"],
["Frightened Rabbit", "An Otherwise Disappointing Life"],
["Frightened Rabbit", "Holy"],
["Frightened Rabbit", "Behave!"],
["Frightened Rabbit", "Old Old Fashioned"],
["Frightened Rabbit", "Yawns"],
["Frightened Rabbit", "I Feel Better"],
["Frightened Rabbit", "Woke Up Hurting"],
["Frightened Rabbit", "Dead Now"],
["Frightened Rabbit", "Poke"],
["Frightened Rabbit", "400 Bones"],
["Frightened Rabbit", "Little Drum"],
["Frightened Rabbit", "Fast Blood"],
["Frightened Rabbit", "Square 9"],
["Frightened Rabbit", "I Wish I Was Sober"],
["Frightened Rabbit", "The Oil Slick"],
["Frightened Rabbit", "Still Want To Be Here"],
["Frightened Rabbit", "Blood Under The Bridge"],
["Frightened Rabbit", "Death Dream"],
["Frightened Rabbit", "Wait 'Til The Morning"],
["Frightened Rabbit", "Not Miserable"],
["Frightened Rabbit", "Snake"],
["Frightened Rabbit", "Acts of Man"],
["Frightened Rabbit", "Living in Colour"],
["Frightened Rabbit", "Housing (in)"],
["Frightened Rabbit", "The Wrestle"],
["Frightened Rabbit", "Go Go Girls"],
["Frightened Rabbit", "December's Traditions"],
["Frightened Rabbit", "Lump Street"],
["Frightened Rabbit", "Keep Yourself Warm"],
["Frightened Rabbit", "The Woodpile"],
["Frightened Rabbit", "Get Out"],
["Judas Priest", "Living Bad Dreams"],
["The Spits", "Bring Me Down"],
["Voltaire", "Feathery Wings"],
["City and Colour", "The Death of Me"],
["Was (Not Was)", "Out Come the Freaks"],
["Bon Jovi", "Hallelujah"],
["Marilyn Dagenais", "Je serai là"],
["Marilyn Dagenais", "J't'écrirai pas"],
["A Lost People", "Big Booty Bitches"],
["Annika Norlin", "Failure"],
["Ascension", "Monsters"],
["Bonnie Prince Billy and Tortoise", "Pancho"],
["Brandi Carlile", "Raise Hell"],
["Britt Daniel", "Let the Distance Bring Us Together"],
["Cyn", "Drinks"],
["Dan Wriggins", "All Used Up"],
["Davey Dynamite & Absent", "Solidarity Forever"],
["Elliott Smith", "Strung Out Again"],
["Emperor X", "Sad React"],
["Girls", "Hellhole Ratrace"],
["Hercules & Love Affair", "Iris"],
["Iris DeMent", "Easy's Gettin' Harder Every Day"],
["Iris DeMent", "Let the Mystery Be"],
["Iris DeMent", "Wasteland of the Free"],
["Joanna Newsom", "Inflammatory Writ"],
["Jukebox The Ghost", "Jumpstarted"],
["Kevin Devine", "Splittin’ Up Christmas"],
["Kirin J Callinan", "Life Is Life"],
["MJ Lenderman", "TLC Cagematch"],
["Molly Hatchet", "Sailor"],
["Necro", "Pussy Is My Weakness"],
["Nevermore", "The Heart Collector"],
["New Found Glory", "Sincerely Me"],
["New Radicals", "I Hope I Didn't Just Give Away The Ending"],
["No Doubt", "Six Feet Under"],
["Petey", "Dont Tell The Boys"],
["Randy Newman", "A Wedding in Cherokee County"],
["Reverend Horton Heat", "Wiggle Stick"],
["Rough Cutt", "Dreamin' Again"],
["Steve Earle", "Christmas in Washington"],
["The Buttertones", "Baby Doll"],
["The Buttertones", "Eros"],
["Whiskey Myers", "Broken Window Serenade"],
["Yoko Kanno", "Whats it For"],
["Mac McCaughan & Annie Hayden", "Down We Go"],
["The Buttertones", "You and Your Knife"],
["The Doubleclicks", "Really Big Chickens"],
["Tony All", "At The Party"],
["Tony All", "Guitar Case"],
["Velvet Pony", "LESBIAN PONIES WITH WEAPONS"],
["Waxahatchee", "Noccalula"],
["David Bowie", "I Know It’s Gonna Happen Someday"],
["Mary Heather Hickman", "Treasure"],
["Ray Price", "The Wind Beneath My Wings"],
["The Avett Brothers", "Ain't No Man"],
["Dropout Kings", "Scratch & Claw"],
["Gogol Bordello", "Not a Crime"],
["Sparks", "Girl from Germany"],
["Sparks", "Under the Table with Her"],
["Streetlight Manifesto", "One Foot on the Gas, One Foot in the Grave"],
["The Doors", "Not to touch the earth"],
["Weird Al Yankovic", "Money for Nothing Beverly Hillbillies"],
["Adam Sandler", "Mr. Bake-O"],
["Eydie Gormé", "The Gentleman is a Dope"],
["Eydie Gormé", "What Did I Have That I Don't Have"],
["Rickie Lee Jones", "The Ballad Of The Sad Young Men"],
["Eddie Cochran", "Three Stars"],
["Lil Durk", "Broadway Girls"],
["Luude", "Down Under"],
[
"Taylor Swift",
"We Are Never Ever Getting Back Together (Taylor's Version)"
],
["The Fray", "Never Say Never"],
["The Ghost Club", "See Below"],
["General Levy", "Incredible (50% Volume Vocals)"],
["General Levy", "Incredible"],
["Marilyn Dagenais", "Chanson pour Papa"],
["Royal Navy", "Heart of Oak"],
["Tiamat", "Cain"],
["Marilyn Dagenais", "You Make Me Sing"],
["Young and Restless", "B Girls"],
["Bug Hunter", "Pinecones"],
["Streetlight Manifesto", "With Any Sort of Certainty"],
["Marvin Gaye", "God is Love"],
["Ben&Ben", "Maybe the Night"],
["Blink 182", "Fell In Love"],
["Blink 182", "Turpentine"],
["Bryson Tiller", "Right My Wrongs"],
["Chris Stapleton", "Joy of My Life"],
["Marilyn Dagenais", "L'hiver"],
["Metric", "Who Would You Be For Me"],
["Rex Orange County", "Happiness"],
["Sheff G", "Weight on Me"],
["Taylor Swift", "I Knew You Were Trouble (Taylor's Version)"],
["Taylor Swift", "You Belong With Me (Taylor's Version)"],
["The 1975", "Robbers"],
["Unknown", "Before the Screen Reads Fin"],
["ACDC", "Gone Shootin'"],
["Ozzy Osbourne", "You're No Different"],
["Alice Cooper", "He's Back (The Man Behind The Mask)"],
["Echo and The Bunnymen", "New Direction"],
["Iggy Pop", "Tell Me a Story"],
["Left Boy", "Security Check"],
["The Lemonheads", "If I Could Talk I’d Tell You"],
["They Might Be Giants", "Dinner Bell"],
["XTC", "Scissor Man"],
["XTC", "The Smartest Monkeys"],
["Marilyn Dagenais", "Un peu de lumière"],
["Bad Lip Reading", "Black Umbrella"],
["Bruno Mars", "The Lazy Song (Non-Lazy Parody)"],
["Marilyn Dagenais", "Si je t'aime"],
["Jerry Lee Lewis", "Meat Man"],
["Shovels & Rope", "Birmingham"],
["Wolfe Tones", "Rock On Rockall"],
["James Rado", "Where Do I Go? (From Hair)"],
["Andrea Bocelli", "Gloria in Excelsis Deo"],
["ABBA", "The Day Before You Came"],
["Fleet Foxes", "He Doesn’t Know Why"],
["The Drifters", "Up On The Roof"],
["The Seekers", "California Dreamin'"],
["Fleet Foxes", "Silver Dagger"],
["She Wants Revenge", "Broken Promises For Broken Hearts"],
["Ken Ashcorp", "On The Rocks"],
["Z-Ro", "Mo City Don Freestyle"],
["The Time", "Cool"],
["Urban Cookie Collective", "The Key, The Secret"],
["Melissa Etheridge", "Meet Me In The Back"],
["Garfunkel And Oates", "I Get to Do It With You"],
["A Fine Frenzy", "Come On, Come Out"],
["A Fine Frenzy", "Rangers"],
["Ken Ashcorp", "PVP"],
["A Fine Frenzy", "Almost Lover"],
["A Fine Frenzy", "You Picked Me"],
["Peach PRC", "God Is A Freak"],
["Righteous Brothers", "See That Girl"],
["Blue Eyed Blondes", "Maneater"],
["piri & tommy", "on & on"],
["Sudley ft. piri", "fumble"],
["A Fine Frenzy", "Ashes And Wine"],
["A Fine Frenzy", "The Minnow & The Trout"],
["Tame Impala", "The Boat I Row"],
["Spinal Tap", "Rainy Day Sun"],
["Röyksopp", "Running To The Sea"],
["Röyksopp", "Oh, Lover"],
["Röyksopp", "Monument"],
["Röyksopp", "Only This Moment"],
["Röyksopp", "The Girl And The Robot"],
["Röyksopp", "49 Percent"],
["Maisi & piri", "head"],
["Django Django", "Default"],
["Django Django", "Hail Bop"],
["piri & tommy", "silver lining"],
["Daniel O'Donnell", "Galway Bay"],
["Daniel O'Donnell", "I'll Take You Home Again Kathleen"],
["Daniel O'Donnell", "Mountains of Mourne"],
[
"Daniel O'Donnell",
"Medley: It's a Long Way to Tipperary / Pack up Your Troubles / If You're Irish, Come into the Parlour"
],
["Jackson Singleton", "Disguise"],
["Ken Ashcorp", "Dare You To Love Me"],
["A Fine Frenzy", "Borrowed Time"],
["A Fine Frenzy", "Last Of Days"],
["A Fine Frenzy", "Hope For The Hopeless"],
["A Fine Frenzy", "Liar, Liar"],
["A Fine Frenzy", "Lifesize"],
["A Fine Frenzy", "Near To You"],
["A Fine Frenzy", "Think Of You"],
["A Fine Frenzy", "Whisper"],
["piri & tommy", "settle"],
["piri & tommy", "soft spot"],
["piri & tommy", "sunlight"],
["piri & tommy", "beachin"],
["piri & tommy", "player 2"],
["piri & tommy", "can we"],
["piri & tommy", "easy"],
["piri & tommy", "say it"],
["piri & tommy", "slowly but surely"],
["piri & tommy", "words"],
["piri & tommy", "nice 2 me"],
["Tony Bennett & k.d.lang", "What A Wonderful World"],
["Ying Yang Twins", "Georgia Dome"],
[
"Daniel O'Donnell",
"Medley: Galway Bay, The Mountains Of Mourne, I'll Take You Home Again Kathleen"
],
["The Beatles", "In My Life"],
["Truck Stop", "Komm her du bist mein Cowboy"],
["Linda Feller", "Du gabst ihr deinen Namen"],
["Victoria OB", "Yeshua"],
["Matthew Morrison", "Somewhere Over the Rainbow"],
["fun.", "Benson Hedges"],
["fun.", "All the Pretty Girls"],
["fun.", "At Least I'm Not as Sad (As I Used to Be)"],
["fun.", "I Wanna Be the One"],
["fun.", "Walking the Dog"],
["fun.", "Light a Roman Candle with Me"],
["fun.", "Barlights"],
["fun.", "Take Your Time (Coming Home)"],
["Tom Astor", "Sturm Und Drang"],
["Titellied der gleichnamigen Fernsehserie 1962", "Bonanza"],
["Linda Feller", "Billy Bob's Texas"],
["ABBA", "Dancing Queen"],
["Ken Ashcorp", "Touch Fluffy Tail"],
["Mavi Phoenix", "Pretty Life (Whsprs Cover)"],
["Jimi Hendrix", "Remember"],
["Smash Mouth", "All Star"],
["Smash Mouth", "All Star (with Shrek)"],
["The Silent Comedy", "Enemies Multiply"],
["ABBA", "Ring Ring"],
["ABBA", "Another Town, Another Train"],
["ABBA", "Disillusion"],
["ABBA", "People Need Love"],
["Frank Sinatra", "New York, New York"],
["ABBA", "I Saw It In The Mirror"],
["ABBA", "Nina, Pretty Ballerina"],
["ABBA", "Love Isn’t Easy (But It Sure Is Hard Enough)"],
["ABBA", "Me And Bobby And Bobby’s Brother"],
["ABBA", "He Is Your Brother"],
["ABBA", "She’s My Kind Of Girl"],
["ABBA", "I Am Just A Girl"],
["ABBA", "Rock ’N Roll Band"],
["ABBA", "Ring Ring (Bara Du Slog En Signal) (Swedish Version)"],
["ABBA", "Åh, Vilka Tider"],
["ABBA", "Merry‐Go‐Round"],
["ABBA", "Santa Rosa"],
["ABBA", "Ring Ring (Spanish Version)"],
["ABBA", "Wer Im Wartesaal Der Liebe Steht"],
["ABBA", "Ring Ring (German Version)"],
["Fleet Foxes", "Montezuma"],
["Harald Juhnke", "Berlin, Berlin"],
["Shoshana Bean", "Strange Thunder"],
["Michael Callen", "Crazy World"],
["Michael Callen", "Wish I Had A Dime"],
["The Blasters", "One Bad Stud"],
["Michael Callen", "The Healing Power Of Love"],
["Meat Loaf", "Braver Than We Are"],
["Harald Juhnke", "Berlin, Berlin (Lisa, Milan)"],
["Friday", "The Ballad Of Skinny Linguine"],
["Emery", "The Ponytail Parades"],
["Black Sabbath", "Buried Alive"],
["Aloha from space", "Storm Troopin'"],
["NerdOut", "Bounty"],
["Charles Strouse and Lee Adams", "Han's Your Man"],
["Juliane Werding", "Man muß Das Leben Eben Nehmen, Wie Das Leben Eben Ist"],
["Aurelio Voltaire", "Butterfly"],
["Blind Guardian", "Violent Shadows"],
["Jonny Hill & Linda Feller", "Zusammenstehn (Duet)"],
["Tori Amos", "Big Wheel"],
["Chairlift", "Bruises"],
["Jonny Hill & Linda Feller", "London"],
["Life Languages", "The Mover Song"],
["Life Languages", "The Responder Song"],
["Life Languages", "The Contemplator Song"],
["Life Languages", "The Doer Song"],
["Life Languages", "The Shaper Song"],
["Life Languages", "The Influencer Song"],
["Life Languages", "The Producer Song"],
["The Amazing Devil", "That Unwanted Animal"],
["Bobby Capo", "Locamente Enamorado"],
["Dagmar", "Lass mich damit bloß in Ruhe"],
["Los Campesinos!", "You! Me! Dancing! (Daytrotter Session)"],
["Joe P", "Leaves"],
["ABBA", "Waterloo"],
["ABBA", "Sitting In The Palmtree"],
["ABBA", "King Kong Song"],
["ABBA", "Hasta Mañana"],
["ABBA", "My Mama Said"],
["ABBA", "Dance (While The Music Still Goes On)"],
["ABBA", "Honey, Honey"],
["Thomas Borchert", "I Know Those Eyes / This Man Is Dead (Duet)"],
[
"Thomas Borchert",
"I Know Those Eyes / This Man Is Dead (Duet With Female Vocals)"
],
["SHE WANTS REVENGE", "Rachael"],
["Matt Redmond", "Unbroken Praise"],
["Ian McConnell", "Level 429"],
["ABBA", "Watch Out"],
["ABBA", "What About Livingstone"],
["Ten Years After", "Outside My Window"],
["ABBA", "Gonna Sing You My Lovesong"],
["ABBA", "Suzy-Hang-Around"],
["ABBA", "Waterloo (Swedish Version)"],
["ABBA", "Honey, Honey (Swedish Version)"],
["ABBA", "Waterloo (German Version)"],
["ABBA", "Hasta Mañana (Spanish Version)"],
["ABBA", "Waterloo (French Version)"],
["ABBA", "Mamma Mia"],
["ABBA", "Hey, Hey Helen"],
["ABBA", "Tropical Loveland"],
["ABBA", "S.O.S."],
["ABBA", "Man In The Middle"],
["ABBA", "Bang-A-Boomerang"],
["ABBA", "I Do, I Do, I Do, I Do, I Do"],
["ABBA", "Rock Me"],
["ABBA", "I’ve Been Waiting For You"],
["ABBA", "So Long"],
["ABBA", "Crazy World"],
["ABBA", "Medley (1978 Mix)"],
["ABBA", "Mamma Mia (Spanish Version)"],
["Marina and The Diamonds", "Froot"],
["Maxton Waller", "On My Way (Marching Band)"],
["100 gecs", "mememe"],
["Stuck Out Here", "Embarrass You"],
["DCSane", "Heart's Whiskey"],
["Release", "Devil's Handshake"],
["Kelly Clarkson", "Since U Been Gone (Pitch -3: E major)"],
["Justin Townes Earle", "Rogers Park"],
["Armin van Buuren ft. Teddy Swims", "Easy To Love"],
["Willie Nelson", "One More Song to Write"],
["Will Varley", "Seize The Night"],
["Passenger", "However It Comes, Wherever It Goes"],
["Ricky Braddy", "Anyone (Acoustic Cover of Demi Lovato)"],
["Bryan Adams", "Help Me Make It Through The Night"],
["Ivan Rivers", "Mid-Riff"],
["Kane Brown", "American Bad Dream"],
["Mother Mother", "Ghosting"],
["Charlie Terrell", "Libby Anna"],
["Taylor Swift", "Fortnight (feat. Post Malone)"],
["The Gaslight Anthem", "National Anthem"],
["The Lonely Island", "Semicolon (feat. Solange)"],
["Lucky Daye", "Algorithm"],
["The Black Eyed Peas", "They Don't Want Music"],
["Tiger Really", "Fundamentally Unlovable"],
["Da Ali G Show", "Jarvis Cocker"],
["Colin Hay", "Send Somebody (Stripped Mix)"],
["Ernie Taylor", "I Ain't Leavin' Yet"],
["Smashing Pumpkins", "Here Is No Why"],
["Drake", "Virginia Beach"],
["Maverick City Music", "I Thank God"],
["Ax and the Hatchetmen", "Drive-in Movie"],
["Faith No More", "Das Schutzenfest"],
["Miguel", "Use Me"],
["Ivan Rivers", "Sad Around Me"],
["Young The Giant", "Both Sides Now"],
["Jimmy Buffett", "Bob Robert's Society Band"],
["buildspace, MAYV", "the end"],
["Frank Turner", "A Wave Across A Bay"],
["Angel Olsen", "Eyes Without A Face"],
["Deven May", "The Sensitive Song (from Cops)"],
["The Mountain Goats", "Night Light"],
["Steppenwolf", "Born To Be Wild"],
["Bobby Solo", "O sole mio"],
["HCA West", "Driving Quality"],
["Engelbert Humperdinck", "Marry Me"],
["Mark Knopfler", "Are We in Trouble Now"],
["Danny Pynes", "One Night in Spain"],
["The Butterfly Effect", "I’m Not Okay"],
["The Sonic Bridges", "Sweet Evelyn"],
["Carrie and Jake", "Wedding Medley"],
["Gregory Porter", "Insanity (feat. Lalah Hathaway)"],
["Linda Feller", "Ich weiss genau, was ich will"],
["Mikey Chuck Rivers", "She's Cryin' (I'm Drunk Again)"],
["Gregory Porter", "Insanity (feat. Lalah Hathaway) (Duet)"],
["Country Rose", "Spaß Am Leben"],
["Tom Astor", "Du bist da (wenn's drum geht)"],
["Linda Feller", "Wenn überhaupt, dann nur Country"],
["Alabama", "The Fans"],
["Ghost Brothers", "What Kind Of Man Am I"],
["The Stand", "Baby, Can You Dig Your Man"],
["Nu Shooz", "I Can't Wait"],
["Freddie Jackson", "All I'll Ever Ask (feat. Najee)"],
["Linda Feller", "Du bist das Salz in meiner Suppe"],
["Claudia Jung, Tom Astor", "Wer Liebe Sucht"],
["The Smashing Pumpkins", "Tales of a Scorched Earth"],
["The Smashing Pumpkins", "Thru the Eyes of Ruby"],
["Tom Astor", "Geistertruck"]
]
+103
View File
@@ -0,0 +1,103 @@
#! /usr/bin/env python3
import os
import json
import logging
from karaoke_prep.karaoke_prep import KaraokePrep
# Set up logging
logger = logging.getLogger(__name__)
log_handler = logging.StreamHandler()
log_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(message)s")
log_handler.setFormatter(log_formatter)
logger.addHandler(log_handler)
logger.setLevel(logging.DEBUG)
# Define the artist/title combinations
def total_length(tuple):
artist, title = tuple
return len(artist) + len(title)
with open("data/artist-titles.json", "r", encoding="utf-8") as f:
all_combinations = json.load(f)
# Sort by length and get shortest and longest 20
sorted_combinations = sorted(all_combinations, key=total_length)
artist_title_combinations = sorted_combinations[:20] + sorted_combinations[-20:]
# Define the format dictionary with expanded configurations
formats = [
{
"name": "nomadkaraoke",
"style_params_json": "/Users/andrew/AB Dropbox/Andrew Beveridge/MediaUnsynced/Karaoke/NomadBranding/karaoke-prep-styles-nomad.json",
},
{
"name": "vocalstar",
"style_params_json": "/Users/andrew/AB Dropbox/Andrew Beveridge/MediaUnsynced/Karaoke/Tracks-NonPublished/VocalStar/Resources/karaoke-prep-styles-vocalstar.json",
},
{
"name": "minimal",
"style_params_json": None,
},
]
# Define other parameters
base_output_dir = "outputs"
os.makedirs(base_output_dir, exist_ok=True)
# Process each format
for format in formats:
# Create format-specific output directory
format_output_dir = os.path.join(base_output_dir, format["name"])
os.makedirs(format_output_dir, exist_ok=True)
style_params = None
if format["style_params_json"]:
with open(format["style_params_json"], "r") as f:
style_params = json.loads(f.read())
# Instantiate KaraokePrep for this format
kprep = KaraokePrep(
log_level=logging.INFO,
log_formatter=log_formatter,
output_dir=format_output_dir,
style_params=style_params,
render_bounding_boxes=False,
output_jpg=False,
output_png=True,
)
# Run the create_title_video and create_end_video functions for each combination
for artist, title in artist_title_combinations:
sanitized_artist = kprep.sanitize_filename(artist)
sanitized_title = kprep.sanitize_filename(title)
# Generate title video
title_image_filepath_noext = os.path.join(format_output_dir, f"{sanitized_artist}_{sanitized_title}_title")
title_video_filepath = os.path.join(format_output_dir, f"{sanitized_artist}_{sanitized_title}_title.mov")
kprep.intro_video_duration = 0
kprep.create_title_video(
artist=artist,
title=title,
format=kprep.title_format,
output_image_filepath_noext=title_image_filepath_noext,
output_video_filepath=title_video_filepath,
)
logger.info(f"Created title video for {artist} - {title} using {format['name']} format")
# Generate end video
end_image_filepath_noext = os.path.join(format_output_dir, f"{sanitized_artist}_{sanitized_title}_end")
end_video_filepath = os.path.join(format_output_dir, f"{sanitized_artist}_{sanitized_title}_end.mov")
kprep.end_video_duration = 0
kprep.create_end_video(
artist=artist,
title=title,
format=kprep.end_format,
output_image_filepath_noext=end_image_filepath_noext,
output_video_filepath=end_video_filepath,
)
logger.info(f"Created end video for {artist} - {title} using {format['name']} format")