mirror of
https://github.com/nomadkaraoke/karaoke-gen.git
synced 2026-11-30 17:21:26 +09:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
27946a1dd8 | ||
|
|
b701920c75 | ||
|
|
0c77999c46 | ||
|
|
341a346865 | ||
|
|
a5a35c710e | ||
|
|
ac774d9aad | ||
|
|
2d988de0a3 | ||
|
|
6a6154fe44 | ||
|
|
f3ebaf5858 | ||
|
|
10554f19ee | ||
|
|
ff90b72a34 | ||
|
|
1e8a23ad50 | ||
|
|
9fbe04ecf8 |
No files matched your search
@@ -17,6 +17,7 @@ This was created to make it easier for me to prepare the source audio, lyrics an
|
||||
- Internet First: Completes operations which require internet first, in case user is preparing last-minute before a period of being offline!
|
||||
- Flexible Input: provide just a YouTube URL, just an artist and title, or both.
|
||||
- Playlist Processing: Capable of processing an entire YouTube playlist, extracting audio and lyrics for each track.
|
||||
- Easy Finalisation: After manually performing your sync (e.g. using [MidiCo](https://www.midicokaraoke.com)), run `karaoke-finalise` to remux and add your title screen!
|
||||
|
||||
## Installation 🛠️
|
||||
|
||||
@@ -24,6 +25,26 @@ You can install Karaoke Prep using pip:
|
||||
|
||||
`pip install karaoke-prep`
|
||||
|
||||
If you aren't sure what `pip` is or how to use the command line, here are some YouTube tutorials which will probably help:
|
||||
|
||||
- Install Python on Windows: https://www.youtube.com/watch?v=YKSpANU8jPE
|
||||
- Command Line basics Windows: https://www.youtube.com/watch?v=MBBWVgE0ewk
|
||||
- Install Python on Mac: https://www.youtube.com/watch?v=3-sPfR4JEQ8
|
||||
- Command Line basics Mac: https://www.youtube.com/watch?v=FfT8OfMpARM
|
||||
|
||||
## Karaoke production guide using karaoke-prep and MidiCo
|
||||
|
||||
- Run `karaoke-prep <Artist> <Title>` to fetch and prep the files above
|
||||
- Wait for it to output at least the WAV file and lyrics (you can leave it running in the background while you sync)
|
||||
- Open the WAV file in MidiCo: `(YouTube xxxxxxxxxxx).wav`
|
||||
- Copy/paste the lyrics into MidiCo: `(Lyrics Processed).txt`
|
||||
- Perform the lyrics sync (here's a [video](https://www.youtube.com/watch?v=63-Fk3mfZ7Q) showing me doing it) in MidiCo
|
||||
- Render the video to 4k using the MidiCo "Export Movie" feature, saving it as `Artist - Title (Karaoke).mov` in the same folder
|
||||
- Run `karaoke-finalise` to remux the instrumental audio and join the title clip to the start
|
||||
- Upload the resulting `Artist - Title (Final Karaoke).mp4` video to YouTube!
|
||||
|
||||
Here's my [tutorial video with verbal explanation](https://www.youtube.com/watch?v=ZsROHgqAVHs) of the whole process, and here's a [normal speed demo](https://www.youtube.com/watch?v=63-Fk3mfZ7Q) of me doing it (8 minutes total for a single track).
|
||||
|
||||
|
||||
## Usage 🚀
|
||||
|
||||
@@ -52,17 +73,21 @@ options:
|
||||
--use_coreml Optional: use Apple Silicon GPU with CoreML for separation (default: False). Example: --use_coreml=true
|
||||
--denoise DENOISE Optional: enable or disable denoising during separation (default: True). Example: --denoise=False
|
||||
--normalize NORMALIZE Optional: enable or disable normalization during separation (default: True). Example: --normalize=False
|
||||
--no_track_subfolders Optional:do NOT create a named subfolder for each track. Example: --no_track_subfolders
|
||||
--no_track_subfolders Optional: do NOT create a named subfolder for each track. Example: --no_track_subfolders
|
||||
--intro_background_color INTRO_BACKGROUND_COLOR Optional: Background color for intro video (default: black). Example: --intro_background_color=#123456
|
||||
--intro_background_image INTRO_BACKGROUND_IMAGE Optional: Path to background image for intro video. Overrides background color if provided. Example: --intro_background_image=path/to/image.jpg
|
||||
--intro_font INTRO_FONT Optional: Font file for intro video (default: Avenir-Next-Bold). Example: --intro_font=AvenirNext-Bold.ttf
|
||||
--intro_artist_color INTRO_ARTIST_COLOR Optional: Font color for intro video artist text (default: #ff7acc). Example: --intro_artist_color=#123456
|
||||
--intro_title_color INTRO_TITLE_COLOR Optional: Font color for intro video title text (default: #ffdf6b). Example: --intro_title_color=#123456
|
||||
```
|
||||
|
||||
|
||||
### Only YouTube URL
|
||||
### ⭐ YouTube URL with Artist and Title
|
||||
|
||||
This will process the video at the given URL, *guessing the artist and title from the YouTube title*.
|
||||
⚠️ Be aware the downloaded lyrics may be incorrect if the video title doesn't match the standard "Artist - Title" format.
|
||||
For the most consistent results, provide a specific YouTube URL along with the artist and title like so:
|
||||
|
||||
```
|
||||
karaoke-prep "https://www.youtube.com/watch?v=YOUR_VIDEO_ID"
|
||||
karaoke-prep "https://www.youtube.com/watch?v=YOUR_VIDEO_ID" "The Fray" "Never Say Never"
|
||||
```
|
||||
|
||||
### Artist and Title Only
|
||||
@@ -73,12 +98,13 @@ If you don't have a specific YouTube URL, just provide the artist and title. Kar
|
||||
karaoke-prep "The Fray" "Never Say Never"
|
||||
```
|
||||
|
||||
### ⭐ YouTube URL with Artist and Title
|
||||
### Only YouTube URL
|
||||
|
||||
For more precise control (and most consistent results), provide the YouTube URL along with the artist and title to avoid any guesswork.
|
||||
This will process the video at the given URL, *guessing the artist and title from the YouTube title*.
|
||||
⚠️ Be aware the downloaded lyrics may be incorrect if the video title doesn't match the standard "Artist - Title" format.
|
||||
|
||||
```
|
||||
karaoke-prep "https://www.youtube.com/watch?v=YOUR_VIDEO_ID" "The Fray" "Never Say Never"
|
||||
karaoke-prep "https://www.youtube.com/watch?v=YOUR_VIDEO_ID"
|
||||
```
|
||||
|
||||
### YouTube Playlist URL
|
||||
@@ -90,16 +116,55 @@ To process a playlist, just provide the playlist URL. The script will process ev
|
||||
karaoke-prep "https://www.youtube.com/playlist?list=YOUR_PLAYLIST_ID"
|
||||
```
|
||||
|
||||
By default, you'll end up with files in the current folder, neatly organised into folders for each track and files named consistently e.g.
|
||||
## Files produced by karaoke-prep and what to do with them
|
||||
|
||||
After running `karaoke-prep` you should have the following 11 files, grouped into folder(s) for each track:
|
||||
|
||||
- `Artist - Title (YouTube xxxxxxxxxxx).webm`
|
||||
- Original unmodified video, fetched from YouTube in the highest quality available
|
||||
- You probably don't need this unless you're creating a custom request
|
||||
- `Artist - Title (YouTube xxxxxxxxxxx).png`
|
||||
- A still image taken from 30 seconds into the video, in case that's useful for a custom background
|
||||
- You probably don't need this unless you're creating a custom request
|
||||
- `Artist - Title (YouTube xxxxxxxxxxx).wav`
|
||||
- Unmodified audio from the YouTube video, converted to WAV format for compatibility
|
||||
- You should open this in MidiCo to begin syncing lyrics to make your karaoke video.
|
||||
- `Artist - Title (Lyrics).txt`
|
||||
- Unmodified lyrics fetched from genius.com based on the artist/title provided
|
||||
- Depending on the song, may have lines which are too long for one karaoke screen
|
||||
- `Artist - Title (Lyrics Processed).txt`
|
||||
- Lyrics from genius, split into lines no longer than 40 characters
|
||||
- You should open this and copy/paste the text into the MidiCo lyrics editor
|
||||
- `Artist - Title (Vocals UVR-MDX-NET-Inst_HQ_3).mp3`
|
||||
- Vocal track from the audio, separated using the UVR Inst_HQ_3 model.
|
||||
- You probably don't need this unless you're trying to tweak the backing track
|
||||
- `Artist - Title (Vocals UVR_MDXNET_KARA_2).mp3`
|
||||
- Vocal track from the audio, separated using the UVR KARA_2 model.
|
||||
- You probably don't need this unless you're trying to tweak the backing track
|
||||
- `Artist - Title (Instrumental UVR-MDX-NET-Inst_HQ_3).mp3`
|
||||
- Instrumental track from the audio, separated using the UVR Inst_HQ_3 model.
|
||||
- This is typically a safe bet for the instrumental track but will not include any backing vocals.
|
||||
- `Artist - Title (Instrumental UVR_MDXNET_KARA_2).mp3`
|
||||
- Instrumental track from the audio, separated using the UVR KARA_2 model.
|
||||
- This is the default choice for the finalisation step below as it usually does a good job of keeping backing vocals. However for some songs it includes far too much or is kinda glitchy, so you should check it before finalising and make a judgement call about using this vs. the Inst_HQ_3 one.
|
||||
- `Artist - Title (Title).png`
|
||||
- Title screen static image; if you specify your own background image, font, color etc. this should give you a convenient way to add a title screen to the start of your video.
|
||||
- `Artist - Title (Title).mov`
|
||||
- 5 second video clip version of the title screen image, ready to be joined by the finalisation step.
|
||||
|
||||
|
||||
## Finalisation 🎥
|
||||
|
||||
After completing your manual sync process and rendering your `Artist - Title (Karaoke).mov` file (still using the original audio!) into the same folder, you can now run `karaoke-finalise`.
|
||||
|
||||
This will output some additional files:
|
||||
- `Artist - Title (Karaoke).mov`
|
||||
- Karaoke video without title screen, remuxed to use the instrumental audio
|
||||
- `Artist - Title (With Vocals).mov`
|
||||
- Karaoke video without title screen, using the original audio (useful for practicing!)
|
||||
- `Artist - Title (Final Karaoke).mp4`
|
||||
- Final karaoke video with 5 second title screen intro, instrumental audio and converted to MP4 for compatibility and reduced file size. Upload this to YouTube!
|
||||
|
||||
```
|
||||
├── Artist - Title (Instrumental UVR-MDX-NET-Inst_HQ_3).flac
|
||||
├── Artist - Title (Instrumental UVR_MDXNET_KARA_2).flac
|
||||
├── Artist - Title (Lyrics).txt
|
||||
├── Artist - Title (Vocals UVR-MDX-NET-Inst_HQ_3).flac
|
||||
├── Artist - Title (Vocals UVR_MDXNET_KARA_2).flac
|
||||
└── Artist - Title (YouTube CNUgemJBLTw).wav
|
||||
```
|
||||
|
||||
## Requirements 📋
|
||||
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
from .karaoke_finalise import KaraokeFinalise
|
||||
@@ -0,0 +1,86 @@
|
||||
import os
|
||||
import subprocess
|
||||
import tempfile
|
||||
import logging
|
||||
|
||||
|
||||
class KaraokeFinalise:
|
||||
def __init__(
|
||||
self,
|
||||
log_level=logging.DEBUG,
|
||||
log_formatter=None,
|
||||
model_name="UVR_MDXNET_KARA_2",
|
||||
):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.logger.setLevel(log_level)
|
||||
self.log_level = log_level
|
||||
self.log_formatter = log_formatter
|
||||
|
||||
self.log_handler = logging.StreamHandler()
|
||||
|
||||
if self.log_formatter is None:
|
||||
self.log_formatter = logging.Formatter("%(asctime)s - %(levelname)s - %(module)s - %(message)s")
|
||||
|
||||
self.log_handler.setFormatter(self.log_formatter)
|
||||
self.logger.addHandler(self.log_handler)
|
||||
|
||||
self.logger.debug(f"KaraokeFinalise instantiating")
|
||||
|
||||
self.model_name = model_name
|
||||
|
||||
def process(self):
|
||||
tracks = []
|
||||
|
||||
for karaoke_file in filter(lambda f: " (Karaoke).mov" in f, os.listdir(".")):
|
||||
base_name = karaoke_file.replace(" (Karaoke).mov", "")
|
||||
artist = base_name.split(" - ")[0]
|
||||
title = base_name.split(" - ")[1]
|
||||
|
||||
with_vocals_file = f"{base_name} (With Vocals).mov"
|
||||
title_file = f"{base_name} (Title).mov"
|
||||
instrumental_file = f"{base_name} (Instrumental {self.model_name}).MP3"
|
||||
final_mp4_file = f"{base_name} (Final Karaoke).mp4"
|
||||
|
||||
track = {
|
||||
"artist": artist,
|
||||
"title": title,
|
||||
"video_with_vocals": with_vocals_file,
|
||||
"video_with_instrumental": karaoke_file,
|
||||
"final_video": final_mp4_file,
|
||||
}
|
||||
|
||||
if os.path.isfile(title_file) and os.path.isfile(karaoke_file) and os.path.isfile(instrumental_file):
|
||||
print("Renaming karaoke file to WithVocals")
|
||||
os.rename(karaoke_file, with_vocals_file)
|
||||
|
||||
print(f"Remuxing karaoke video with instrumental audio to '{karaoke_file}'")
|
||||
subprocess.run(
|
||||
["ffmpeg", "-an", "-i", with_vocals_file, "-vn", "-i", instrumental_file, "-c:v", "copy", "-c:a", "aac", karaoke_file]
|
||||
)
|
||||
|
||||
print(f"Joining '{title_file}' and '{karaoke_file}' into '{final_mp4_file}'")
|
||||
with tempfile.NamedTemporaryFile(mode="w+", delete=False, dir="/tmp", suffix=".txt") as tmp_file_list:
|
||||
tmp_file_list.write(f"file '{os.path.abspath(title_file)}'\n")
|
||||
tmp_file_list.write(f"file '{os.path.abspath(karaoke_file)}'\n")
|
||||
subprocess.run(
|
||||
[
|
||||
"ffmpeg",
|
||||
"-f",
|
||||
"concat",
|
||||
"-safe",
|
||||
"0",
|
||||
"-i",
|
||||
tmp_file_list.name,
|
||||
"-vf",
|
||||
"settb=AVTB,setpts=N/30/TB,fps=30",
|
||||
final_mp4_file,
|
||||
]
|
||||
)
|
||||
|
||||
os.remove(tmp_file_list.name)
|
||||
else:
|
||||
print(f"Required files for '{base_name}' not found.")
|
||||
|
||||
tracks.append(track)
|
||||
|
||||
return tracks
|
||||
+161
-65
@@ -29,8 +29,8 @@ class KaraokePrep:
|
||||
intro_background_color="#000000",
|
||||
intro_background_image=None,
|
||||
intro_font="AvenirNext-Bold.ttf",
|
||||
intro_artist_color="#ff7acc",
|
||||
intro_title_color="#ffdf6b",
|
||||
intro_artist_color="#ffffff",
|
||||
intro_title_color="#ff7acc",
|
||||
):
|
||||
self.logger = logging.getLogger(__name__)
|
||||
self.logger.setLevel(log_level)
|
||||
@@ -60,11 +60,24 @@ class KaraokePrep:
|
||||
self.normalization_enabled = normalization_enabled
|
||||
self.denoise_enabled = denoise_enabled
|
||||
self.create_track_subfolders = create_track_subfolders
|
||||
self.intro_background_color = intro_background_color
|
||||
self.intro_background_image = intro_background_image
|
||||
self.intro_font = intro_font
|
||||
self.intro_artist_color = intro_artist_color
|
||||
self.intro_title_color = intro_title_color
|
||||
|
||||
self.ffmpeg_base_command = "ffmpeg -hide_banner -nostats"
|
||||
|
||||
if self.log_level == logging.DEBUG:
|
||||
self.ffmpeg_base_command += " -loglevel verbose"
|
||||
else:
|
||||
self.ffmpeg_base_command += " -loglevel fatal"
|
||||
|
||||
self.title_format = {
|
||||
"background_color": intro_background_color,
|
||||
"background_image": intro_background_image,
|
||||
"artist_font": intro_font,
|
||||
"title_font": intro_font,
|
||||
"artist_color": intro_artist_color,
|
||||
"title_color": intro_title_color,
|
||||
}
|
||||
|
||||
self.persistent_artist = None
|
||||
|
||||
self.logger.debug(f"KaraokePrep output_format: {self.output_format}")
|
||||
|
||||
@@ -82,6 +95,8 @@ class KaraokePrep:
|
||||
with yt_dlp.YoutubeDL({"quiet": True}) as ydl:
|
||||
info = ydl.extract_info(self.url, download=False)
|
||||
self.artist, self.title = self.parse_metadata(info)
|
||||
if self.persistent_artist:
|
||||
self.artist = self.persistent_artist
|
||||
if self.artist and self.title:
|
||||
self.logger.info(f"Extracted artist: {self.artist}, title: {self.title}")
|
||||
else:
|
||||
@@ -143,14 +158,18 @@ class KaraokePrep:
|
||||
|
||||
def extract_still_image_from_video(self, input_filename, output_filename_no_extension):
|
||||
output_filename = output_filename_no_extension + ".png"
|
||||
self.logger.debug(f"Extracting still image from position 30s YouTube video to {output_filename}")
|
||||
os.system(f'ffmpeg -i "{input_filename}" -ss 00:00:30 -vframes 1 "{output_filename}"')
|
||||
self.logger.info(f"Extracting still image from position 30s YouTube video")
|
||||
ffmpeg_command = f'{self.ffmpeg_base_command} -i "{input_filename}" -ss 00:00:30 -vframes 1 "{output_filename}"'
|
||||
self.logger.debug(f"Running command: {ffmpeg_command}")
|
||||
os.system(ffmpeg_command)
|
||||
return output_filename
|
||||
|
||||
def convert_to_wav(self, input_filename, output_filename_no_extension):
|
||||
output_filename = output_filename_no_extension + ".wav"
|
||||
self.logger.debug(f"Converting {input_filename} to WAV file {output_filename}")
|
||||
os.system(f'ffmpeg -i "{input_filename}" "{output_filename}"')
|
||||
self.logger.info(f"Converting input video to audio WAV file")
|
||||
ffmpeg_command = f'{self.ffmpeg_base_command} -i "{input_filename}" "{output_filename}"'
|
||||
self.logger.debug(f"Running command: {ffmpeg_command}")
|
||||
os.system(ffmpeg_command)
|
||||
return output_filename
|
||||
|
||||
def write_lyrics_from_genius(self, artist, title, filename):
|
||||
@@ -163,6 +182,7 @@ class KaraokePrep:
|
||||
f.write(lyrics)
|
||||
|
||||
self.logger.info("Lyrics for %s by %s fetched successfully", title, artist)
|
||||
return lyrics.split("\n")
|
||||
else:
|
||||
self.logger.warning("Could not find lyrics for %s by %s", title, artist)
|
||||
|
||||
@@ -179,6 +199,54 @@ class KaraokePrep:
|
||||
# add any additional cleaning rules here
|
||||
return lyrics
|
||||
|
||||
def find_best_split_point(self, line):
|
||||
"""
|
||||
Find the best split point in a line based on the specified criteria.
|
||||
"""
|
||||
|
||||
self.logger.debug(f"Finding best_split_point for line: {line}")
|
||||
words = line.split()
|
||||
mid_word_index = len(words) // 2
|
||||
|
||||
# Check for a comma within one or two words of the middle word
|
||||
if "," in line:
|
||||
mid_point = len(" ".join(words[:mid_word_index]))
|
||||
comma_indices = [i for i, char in enumerate(line) if char == ","]
|
||||
|
||||
for index in comma_indices:
|
||||
if abs(mid_point - index) < 20: # Roughly the length of two average words
|
||||
self.logger.debug(
|
||||
f"Found comma at index {index} which is within 20 characters of mid_point {mid_point}, accepting as split point"
|
||||
)
|
||||
return index + 1 # Include the comma in the first line
|
||||
|
||||
# Check for 'and'
|
||||
if " and " in line:
|
||||
mid_point = len(line) // 2
|
||||
and_indices = [m.start() for m in re.finditer(" and ", line)]
|
||||
split_point = min(and_indices, key=lambda x: abs(x - mid_point))
|
||||
self.logger.debug(f"Found 'and' at index {split_point} which is close to mid_point {mid_point}, accepting as split point")
|
||||
return split_point + len(" and ") # Include 'and' in the first line
|
||||
|
||||
# Split at the middle word
|
||||
self.logger.debug(f"No comma or suitable 'and' found, using middle word as split point")
|
||||
return len(" ".join(words[:mid_word_index]))
|
||||
|
||||
def write_processed_lyrics(self, lyrics, processed_lyrics_file):
|
||||
self.logger.debug(f"Writing processed lyrics to {processed_lyrics_file}")
|
||||
|
||||
with open(processed_lyrics_file, "w") as outfile:
|
||||
for line in lyrics:
|
||||
line = line.strip()
|
||||
if len(line) > 40:
|
||||
self.logger.debug(f"Line is longer than 40 characters, splitting at best split point: {line}")
|
||||
split_point = self.find_best_split_point(line)
|
||||
outfile.write(line[:split_point].strip() + "\n")
|
||||
outfile.write(line[split_point:].strip() + "\n")
|
||||
else:
|
||||
self.logger.debug(f"Line is shorter than 40 characters, writing as-is: {line}")
|
||||
outfile.write(line + "\n")
|
||||
|
||||
def sanitize_filename(self, filename):
|
||||
"""Replace or remove characters that are unsafe for filenames."""
|
||||
# Replace problematic characters with underscores
|
||||
@@ -228,69 +296,89 @@ class KaraokePrep:
|
||||
|
||||
return track_output_dir, artist_title
|
||||
|
||||
def create_intro_video(self, artist, title, output_filename):
|
||||
def calculate_text_size_and_position(self, draw, text, font_path, start_size, resolution, padding):
|
||||
font_size = start_size
|
||||
font = ImageFont.truetype(font_path, size=font_size) if os.path.exists(font_path) else ImageFont.load_default()
|
||||
|
||||
# Initial position for calculating the text bounding box
|
||||
temp_position = (padding, padding)
|
||||
bbox = draw.textbbox(temp_position, text, font=font)
|
||||
text_width = bbox[2] - bbox[0]
|
||||
text_height = bbox[3] - bbox[1]
|
||||
|
||||
while text_width + 2 * padding > resolution[0] or text_height + 2 * padding > resolution[1]:
|
||||
font_size -= 10
|
||||
if font_size <= 0:
|
||||
raise ValueError("Cannot fit text within screen bounds.")
|
||||
font = ImageFont.truetype(font_path, size=font_size) if os.path.exists(font_path) else ImageFont.load_default()
|
||||
bbox = draw.textbbox(temp_position, text, font=font)
|
||||
text_width = bbox[2] - bbox[0]
|
||||
text_height = bbox[3] - bbox[1]
|
||||
|
||||
text_position = ((resolution[0] - text_width) // 2, (resolution[1] - text_height) // 2)
|
||||
return font, text_position
|
||||
|
||||
def calculate_text_position(self, draw, text, font, resolution, vertical_offset):
|
||||
bbox = draw.textbbox((0, 0), text, font=font)
|
||||
text_width = bbox[2] - bbox[0]
|
||||
text_height = bbox[3] - bbox[1]
|
||||
text_x = (resolution[0] - text_width) // 2
|
||||
text_y = vertical_offset
|
||||
return (text_x, text_y), text_height
|
||||
|
||||
def create_title_video(self, artist, title, format, output_image_filepath, output_video_filepath):
|
||||
duration = 5 # Duration in seconds
|
||||
resolution = (3840, 2160) # 4K resolution
|
||||
font_size = 400 # Adjust as needed
|
||||
line_spacing = 50 # Adjust as needed
|
||||
|
||||
# Load or create background image
|
||||
if self.intro_background_image:
|
||||
background = Image.open(self.intro_background_image)
|
||||
if format["background_image"] and os.path.exists(format["background_image"]):
|
||||
self.logger.info(f"Using title screen background image file: {format['background_image']}")
|
||||
background = Image.open(format["background_image"])
|
||||
else:
|
||||
background = Image.new("RGB", resolution, color=self.hex_to_rgb(self.intro_background_color))
|
||||
self.logger.info(f"Using title screen background color: {format['background_color']}")
|
||||
background = Image.new("RGB", resolution, color=self.hex_to_rgb(format["background_color"]))
|
||||
|
||||
# Resize background to match resolution
|
||||
background = background.resize(resolution)
|
||||
|
||||
# Create an ImageDraw instance
|
||||
title = title.upper()
|
||||
artist = artist.upper()
|
||||
|
||||
initial_font_size = 500
|
||||
top_padding = 950
|
||||
title_padding = 400
|
||||
artist_padding = 700
|
||||
fixed_gap = 150
|
||||
|
||||
draw = ImageDraw.Draw(background)
|
||||
|
||||
# Check if the font file exists, if not use a default font
|
||||
if os.path.exists(self.intro_font):
|
||||
font = ImageFont.truetype(self.intro_font, size=font_size)
|
||||
else:
|
||||
self.logger.warning(f"Font file not found: {self.intro_font}. Using default font.")
|
||||
font = ImageFont.load_default(size=font_size)
|
||||
# Calculate positions and sizes for title and artist
|
||||
title_font, _ = self.calculate_text_size_and_position(
|
||||
draw, title, format["title_font"], initial_font_size, resolution, title_padding
|
||||
)
|
||||
artist_font, _ = self.calculate_text_size_and_position(
|
||||
draw, artist, format["artist_font"], initial_font_size, resolution, artist_padding
|
||||
)
|
||||
|
||||
# Calculate text width using the ImageDraw instance
|
||||
artist_text_width = draw.textlength(artist, font=font)
|
||||
title_text_width = draw.textlength(title, font=font)
|
||||
# Calculate vertical positions with consistent gap
|
||||
title_text_position, title_height = self.calculate_text_position(draw, title, title_font, resolution, top_padding)
|
||||
artist_text_position, _ = self.calculate_text_position(
|
||||
draw, artist, artist_font, resolution, title_text_position[1] + title_height + fixed_gap
|
||||
)
|
||||
|
||||
# Calculate text positions
|
||||
artist_text_position = ((resolution[0] - artist_text_width) // 2, resolution[1] // 2 - font_size - line_spacing)
|
||||
title_text_position = ((resolution[0] - title_text_width) // 2, resolution[1] // 2 + line_spacing)
|
||||
draw.text(title_text_position, title, fill=format["title_color"], font=title_font)
|
||||
draw.text(artist_text_position, artist, fill=format["artist_color"], font=artist_font)
|
||||
|
||||
# Draw text
|
||||
draw.text(artist_text_position, artist, fill=self.intro_artist_color, font=font)
|
||||
draw.text(title_text_position, title, fill=self.intro_title_color, font=font)
|
||||
|
||||
# Save to a temporary image file
|
||||
temp_image_path = "/tmp/temp_background.png"
|
||||
background.save(temp_image_path)
|
||||
self.logger.warning(f"Temporarily saving background image to {temp_image_path}")
|
||||
# Save static background image
|
||||
background.save(output_image_filepath)
|
||||
|
||||
# Use ffmpeg to create video
|
||||
ffmpeg_command = [
|
||||
"ffmpeg",
|
||||
"-y", # Overwrite output files without asking
|
||||
"-loop", # Loop the input image
|
||||
"1", # Loop the input image
|
||||
"-i", # Input file
|
||||
temp_image_path, # Input file
|
||||
"-c:v", # Video codec
|
||||
"libx264", # Video codec
|
||||
"-t", # Duration
|
||||
str(duration), # Duration
|
||||
"-pix_fmt", # Pixel format
|
||||
"yuv420p", # Pixel format
|
||||
"-vf", # Video filter
|
||||
f"scale={resolution[0]}:{resolution[1]}", # Video filter
|
||||
output_filename, # Output filename
|
||||
]
|
||||
ffmpeg_command = f'{self.ffmpeg_base_command} -y -loop 1 -framerate 30 -i "{output_image_filepath}" -f lavfi -i anullsrc '
|
||||
ffmpeg_command += f'-c:v libx264 -r 30 -t {duration} -pix_fmt yuv420p -vf scale={resolution[0]}:{resolution[1]} -c:a aac -shortest "{output_video_filepath}"'
|
||||
|
||||
subprocess.run(ffmpeg_command)
|
||||
# os.remove(temp_image_path)
|
||||
self.logger.info("Generating title video...")
|
||||
self.logger.debug(f"Running command: {ffmpeg_command}")
|
||||
os.system(ffmpeg_command)
|
||||
|
||||
def hex_to_rgb(self, hex_color):
|
||||
"""Convert hex color to RGB tuple."""
|
||||
@@ -305,7 +393,7 @@ class KaraokePrep:
|
||||
artist = self.artist
|
||||
title = self.title
|
||||
|
||||
self.logger.info(f"Downloading inputs for track: {title} by {artist}")
|
||||
self.logger.info(f"Preparing output path for track: {title} by {artist}")
|
||||
track_output_dir, artist_title = self.setup_output_paths(artist, title)
|
||||
processed_track = {
|
||||
"track_output_dir": track_output_dir,
|
||||
@@ -313,6 +401,11 @@ class KaraokePrep:
|
||||
"title": title,
|
||||
}
|
||||
|
||||
self.logger.info(f"Creating title video...")
|
||||
processed_track["title_image"] = os.path.join(track_output_dir, f"{artist_title} (Title).png")
|
||||
processed_track["title_video"] = os.path.join(track_output_dir, f"{artist_title} (Title).mov")
|
||||
self.create_title_video(artist, title, self.title_format, processed_track["title_image"], processed_track["title_video"])
|
||||
|
||||
yt_webm_filename_pattern = os.path.join(track_output_dir, f"{artist_title} (YouTube *.webm")
|
||||
yt_webm_glob = glob.glob(yt_webm_filename_pattern)
|
||||
|
||||
@@ -358,16 +451,16 @@ class KaraokePrep:
|
||||
self.logger.warning(f"Skipping {title} by {artist} due to missing YouTube ID.")
|
||||
|
||||
lyrics_file = os.path.join(track_output_dir, f"{artist_title} (Lyrics).txt")
|
||||
processed_lyrics_file = os.path.join(track_output_dir, f"{artist_title} (Lyrics Processed).txt")
|
||||
if os.path.exists(lyrics_file):
|
||||
self.logger.debug(f"Lyrics file already exists, skipping fetch: {lyrics_file}")
|
||||
else:
|
||||
self.logger.info("Fetching lyrics from Genius...")
|
||||
self.write_lyrics_from_genius(artist, title, lyrics_file)
|
||||
lyrics = self.write_lyrics_from_genius(artist, title, lyrics_file)
|
||||
self.write_processed_lyrics(lyrics, processed_lyrics_file)
|
||||
|
||||
processed_track["lyrics"] = lyrics_file
|
||||
|
||||
intro_filename = os.path.join(track_output_dir, f"{artist_title} (Intro).mp4")
|
||||
self.create_intro_video(artist, title, intro_filename)
|
||||
processed_track["processed_lyrics"] = processed_lyrics_file
|
||||
|
||||
self.logger.info(f"Separating audio twice for track: {title} by {artist}")
|
||||
|
||||
@@ -409,7 +502,7 @@ class KaraokePrep:
|
||||
"""
|
||||
Processes all videos in a YouTube playlist.
|
||||
"""
|
||||
self.logger.debug("Querying playlist metadata from YouTube...")
|
||||
self.logger.debug(f"Querying playlist metadata from YouTube, assuming consistent artist {self.artist}...")
|
||||
with yt_dlp.YoutubeDL({"quiet": True}) as ydl:
|
||||
result = ydl.extract_info(self.url, download=False)
|
||||
if "entries" in result:
|
||||
@@ -420,13 +513,16 @@ class KaraokePrep:
|
||||
self.logger.info(f"Processing video: {video_url}")
|
||||
self.url = video_url
|
||||
track_results.append(self.prep_single_track())
|
||||
self.artist = None
|
||||
self.artist = self.persistent_artist
|
||||
self.title = None
|
||||
return track_results
|
||||
|
||||
def process(self):
|
||||
if self.is_playlist_url():
|
||||
self.logger.info(f"Provided YouTube URL is a playlist, beginning batch operation")
|
||||
self.persistent_artist = self.artist
|
||||
self.logger.info(
|
||||
f"Provided YouTube URL is a playlist, beginning batch operation with persistent artist: {self.persistent_artist}"
|
||||
)
|
||||
return self.process_playlist()
|
||||
else:
|
||||
self.logger.info(f"Provided YouTube URL is NOT a playlist, processing single track")
|
||||
|
||||
Generated
+68
-1
@@ -1150,6 +1150,73 @@ files = [
|
||||
{file = "pathspec-0.12.1.tar.gz", hash = "sha256:a482d51503a1ab33b1c67a6c3813a26953dbdc71c31dacaef9a838c4e29f5712"},
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "pillow"
|
||||
version = "10.1.0"
|
||||
description = "Python Imaging Library (Fork)"
|
||||
optional = false
|
||||
python-versions = ">=3.8"
|
||||
files = [
|
||||
{file = "Pillow-10.1.0-cp310-cp310-macosx_10_10_x86_64.whl", hash = "sha256:1ab05f3db77e98f93964697c8efc49c7954b08dd61cff526b7f2531a22410106"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:6932a7652464746fcb484f7fc3618e6503d2066d853f68a4bd97193a3996e273"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:a5f63b5a68daedc54c7c3464508d8c12075e56dcfbd42f8c1bf40169061ae666"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:c0949b55eb607898e28eaccb525ab104b2d86542a85c74baf3a6dc24002edec2"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-manylinux_2_28_aarch64.whl", hash = "sha256:ae88931f93214777c7a3aa0a8f92a683f83ecde27f65a45f95f22d289a69e593"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-manylinux_2_28_x86_64.whl", hash = "sha256:b0eb01ca85b2361b09480784a7931fc648ed8b7836f01fb9241141b968feb1db"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-musllinux_1_1_aarch64.whl", hash = "sha256:d27b5997bdd2eb9fb199982bb7eb6164db0426904020dc38c10203187ae2ff2f"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:7df5608bc38bd37ef585ae9c38c9cd46d7c81498f086915b0f97255ea60c2818"},
|
||||
{file = "Pillow-10.1.0-cp310-cp310-win_amd64.whl", hash = "sha256:41f67248d92a5e0a2076d3517d8d4b1e41a97e2df10eb8f93106c89107f38b57"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-macosx_10_10_x86_64.whl", hash = "sha256:1fb29c07478e6c06a46b867e43b0bcdb241b44cc52be9bc25ce5944eed4648e7"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:2cdc65a46e74514ce742c2013cd4a2d12e8553e3a2563c64879f7c7e4d28bce7"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:50d08cd0a2ecd2a8657bd3d82c71efd5a58edb04d9308185d66c3a5a5bed9610"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:062a1610e3bc258bff2328ec43f34244fcec972ee0717200cb1425214fe5b839"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-manylinux_2_28_aarch64.whl", hash = "sha256:61f1a9d247317fa08a308daaa8ee7b3f760ab1809ca2da14ecc88ae4257d6172"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-manylinux_2_28_x86_64.whl", hash = "sha256:a646e48de237d860c36e0db37ecaecaa3619e6f3e9d5319e527ccbc8151df061"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-musllinux_1_1_aarch64.whl", hash = "sha256:47e5bf85b80abc03be7455c95b6d6e4896a62f6541c1f2ce77a7d2bb832af262"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:a92386125e9ee90381c3369f57a2a50fa9e6aa8b1cf1d9c4b200d41a7dd8e992"},
|
||||
{file = "Pillow-10.1.0-cp311-cp311-win_amd64.whl", hash = "sha256:0f7c276c05a9767e877a0b4c5050c8bee6a6d960d7f0c11ebda6b99746068c2a"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-macosx_10_10_x86_64.whl", hash = "sha256:a89b8312d51715b510a4fe9fc13686283f376cfd5abca8cd1c65e4c76e21081b"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:00f438bb841382b15d7deb9a05cc946ee0f2c352653c7aa659e75e592f6fa17d"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:3d929a19f5469b3f4df33a3df2983db070ebb2088a1e145e18facbc28cae5b27"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:9a92109192b360634a4489c0c756364c0c3a2992906752165ecb50544c251312"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:0248f86b3ea061e67817c47ecbe82c23f9dd5d5226200eb9090b3873d3ca32de"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:9882a7451c680c12f232a422730f986a1fcd808da0fd428f08b671237237d651"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:1c3ac5423c8c1da5928aa12c6e258921956757d976405e9467c5f39d1d577a4b"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:806abdd8249ba3953c33742506fe414880bad78ac25cc9a9b1c6ae97bedd573f"},
|
||||
{file = "Pillow-10.1.0-cp312-cp312-win_amd64.whl", hash = "sha256:eaed6977fa73408b7b8a24e8b14e59e1668cfc0f4c40193ea7ced8e210adf996"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-macosx_10_10_x86_64.whl", hash = "sha256:fe1e26e1ffc38be097f0ba1d0d07fcade2bcfd1d023cda5b29935ae8052bd793"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7a7e3daa202beb61821c06d2517428e8e7c1aab08943e92ec9e5755c2fc9ba5e"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:24fadc71218ad2b8ffe437b54876c9382b4a29e030a05a9879f615091f42ffc2"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:fa1d323703cfdac2036af05191b969b910d8f115cf53093125e4058f62012c9a"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-manylinux_2_28_aarch64.whl", hash = "sha256:912e3812a1dbbc834da2b32299b124b5ddcb664ed354916fd1ed6f193f0e2d01"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-manylinux_2_28_x86_64.whl", hash = "sha256:7dbaa3c7de82ef37e7708521be41db5565004258ca76945ad74a8e998c30af8d"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-musllinux_1_1_aarch64.whl", hash = "sha256:9d7bc666bd8c5a4225e7ac71f2f9d12466ec555e89092728ea0f5c0c2422ea80"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:baada14941c83079bf84c037e2d8b7506ce201e92e3d2fa0d1303507a8538212"},
|
||||
{file = "Pillow-10.1.0-cp38-cp38-win_amd64.whl", hash = "sha256:2ef6721c97894a7aa77723740a09547197533146fba8355e86d6d9a4a1056b14"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-macosx_10_10_x86_64.whl", hash = "sha256:0a026c188be3b443916179f5d04548092e253beb0c3e2ee0a4e2cdad72f66099"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:04f6f6149f266a100374ca3cc368b67fb27c4af9f1cc8cb6306d849dcdf12616"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:bb40c011447712d2e19cc261c82655f75f32cb724788df315ed992a4d65696bb"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1a8413794b4ad9719346cd9306118450b7b00d9a15846451549314a58ac42219"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-manylinux_2_28_aarch64.whl", hash = "sha256:c9aeea7b63edb7884b031a35305629a7593272b54f429a9869a4f63a1bf04c34"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-manylinux_2_28_x86_64.whl", hash = "sha256:b4005fee46ed9be0b8fb42be0c20e79411533d1fd58edabebc0dd24626882cfd"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-musllinux_1_1_aarch64.whl", hash = "sha256:4d0152565c6aa6ebbfb1e5d8624140a440f2b99bf7afaafbdbf6430426497f28"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:d921bc90b1defa55c9917ca6b6b71430e4286fc9e44c55ead78ca1a9f9eba5f2"},
|
||||
{file = "Pillow-10.1.0-cp39-cp39-win_amd64.whl", hash = "sha256:cfe96560c6ce2f4c07d6647af2d0f3c54cc33289894ebd88cfbb3bcd5391e256"},
|
||||
{file = "Pillow-10.1.0-pp310-pypy310_pp73-macosx_10_10_x86_64.whl", hash = "sha256:937bdc5a7f5343d1c97dc98149a0be7eb9704e937fe3dc7140e229ae4fc572a7"},
|
||||
{file = "Pillow-10.1.0-pp310-pypy310_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:b1c25762197144e211efb5f4e8ad656f36c8d214d390585d1d21281f46d556ba"},
|
||||
{file = "Pillow-10.1.0-pp310-pypy310_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:afc8eef765d948543a4775f00b7b8c079b3321d6b675dde0d02afa2ee23000b4"},
|
||||
{file = "Pillow-10.1.0-pp310-pypy310_pp73-win_amd64.whl", hash = "sha256:883f216eac8712b83a63f41b76ddfb7b2afab1b74abbb413c5df6680f071a6b9"},
|
||||
{file = "Pillow-10.1.0-pp39-pypy39_pp73-macosx_10_10_x86_64.whl", hash = "sha256:b920e4d028f6442bea9a75b7491c063f0b9a3972520731ed26c83e254302eb1e"},
|
||||
{file = "Pillow-10.1.0-pp39-pypy39_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:1c41d960babf951e01a49c9746f92c5a7e0d939d1652d7ba30f6b3090f27e412"},
|
||||
{file = "Pillow-10.1.0-pp39-pypy39_pp73-manylinux_2_28_x86_64.whl", hash = "sha256:1fafabe50a6977ac70dfe829b2d5735fd54e190ab55259ec8aea4aaea412fa0b"},
|
||||
{file = "Pillow-10.1.0-pp39-pypy39_pp73-win_amd64.whl", hash = "sha256:3b834f4b16173e5b92ab6566f0473bfb09f939ba14b23b8da1f54fa63e4b623f"},
|
||||
{file = "Pillow-10.1.0.tar.gz", hash = "sha256:e6bf8de6c36ed96c86ea3b6e1d5273c53f46ef518a062464cd7ef5dd2cf92e38"},
|
||||
]
|
||||
|
||||
[package.extras]
|
||||
docs = ["furo", "olefile", "sphinx (>=2.4)", "sphinx-copybutton", "sphinx-inline-tabs", "sphinx-removed-in", "sphinxext-opengraph"]
|
||||
tests = ["check-manifest", "coverage", "defusedxml", "markdown2", "olefile", "packaging", "pyroma", "pytest", "pytest-cov", "pytest-timeout"]
|
||||
|
||||
[[package]]
|
||||
name = "platformdirs"
|
||||
version = "4.1.0"
|
||||
@@ -1715,4 +1782,4 @@ websockets = "*"
|
||||
[metadata]
|
||||
lock-version = "2.0"
|
||||
python-versions = ">=3.9"
|
||||
content-hash = "f28f46038a5e2dd2ee43818c0014da722961db5ed4d3ae621504d66586050a84"
|
||||
content-hash = "b36700c08629f5c61e7a0332791c0688650c6b9c428e3bf9dd441290249f44ac"
|
||||
+5
-3
@@ -1,7 +1,7 @@
|
||||
[tool.poetry]
|
||||
name = "karaoke-prep"
|
||||
version = "0.4.3"
|
||||
description = "Prepare for karaoke video creation, by downloading audio and lyrics for a specified song or youtube playlist and separatung audio stems."
|
||||
version = "0.6.4"
|
||||
description = "Prepare for karaoke video creation, by downloading audio and lyrics for a specified song or youtube playlist and separatung audio stems, then finalise the video with a title screen after manual syncing!"
|
||||
authors = ["Andrew Beveridge <andrew@beveridge.uk>"]
|
||||
license = "MIT"
|
||||
readme = "README.md"
|
||||
@@ -18,12 +18,14 @@ yt-dlp = "*"
|
||||
lyricsgenius = "^3"
|
||||
fetch-lyrics-from-genius = "^0.1"
|
||||
audio-separator = "^0.8"
|
||||
pillow = "^10.1.0"
|
||||
|
||||
[tool.poetry.group.dev.dependencies]
|
||||
black = "^23"
|
||||
|
||||
[tool.poetry.scripts]
|
||||
karaoke-prep = 'karaoke_prep.utils.cli:main'
|
||||
karaoke-prep = 'utils.prep_cli:main'
|
||||
karaoke-finalise = 'utils.finalise_cli:main'
|
||||
|
||||
[tool.black]
|
||||
line-length = 140
|
||||
|
||||
File renamed without changes.
@@ -0,0 +1,61 @@
|
||||
#!/usr/bin/env python
|
||||
import argparse
|
||||
import logging
|
||||
import pkg_resources
|
||||
from karaoke_finalise import KaraokeFinalise
|
||||
|
||||
|
||||
def main():
|
||||
logger = logging.getLogger(__name__)
|
||||
log_handler = logging.StreamHandler()
|
||||
log_formatter = logging.Formatter(fmt="%(asctime)s.%(msecs)03d - %(levelname)s - %(module)s - %(message)s", datefmt="%Y-%m-%d %H:%M:%S")
|
||||
log_handler.setFormatter(log_formatter)
|
||||
logger.addHandler(log_handler)
|
||||
|
||||
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),
|
||||
)
|
||||
|
||||
package_version = pkg_resources.get_distribution("karaoke-prep").version
|
||||
parser.add_argument("-v", "--version", action="version", version=f"%(prog)s {package_version}")
|
||||
|
||||
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(
|
||||
"--model_name",
|
||||
default="UVR_MDXNET_KARA_2",
|
||||
help="Optional: model name to be used for separation (default: %(default)s). Example: --model_name=UVR-MDX-NET-Inst_HQ_3",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
|
||||
log_level = getattr(logging, args.log_level.upper())
|
||||
logger.setLevel(log_level)
|
||||
|
||||
logger.info(f"KaraokeFinalise beginning with model_name: {args.model_name}")
|
||||
|
||||
kfinalise = KaraokeFinalise(
|
||||
log_formatter=log_formatter,
|
||||
log_level=log_level,
|
||||
model_name=args.model_name,
|
||||
)
|
||||
|
||||
tracks = kfinalise.process()
|
||||
|
||||
logger.info(f"Karaoke Finalisation complete! Output files:")
|
||||
|
||||
for track in tracks:
|
||||
logger.info(f"")
|
||||
logger.info(f"Track: {track['artist']} - {track['title']}")
|
||||
logger.info(f" Video With Vocals: {track['video_with_vocals']}")
|
||||
logger.info(f" Video With Instrumental: {track['video_with_instrumental']}")
|
||||
logger.info(f" Final Video with Title Screen: {track['final_video']}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@@ -95,7 +95,7 @@ def main():
|
||||
|
||||
parser.add_argument(
|
||||
"--intro_background_color",
|
||||
default="black",
|
||||
default="#000000",
|
||||
help="Optional: Background color for intro video (default: black). Example: --intro_background_color=#123456",
|
||||
)
|
||||
|
||||
@@ -112,14 +112,14 @@ def main():
|
||||
|
||||
parser.add_argument(
|
||||
"--intro_artist_color",
|
||||
default="#ff7acc",
|
||||
help="Optional: Font color for intro video artist text (default: #ff7acc). Example: --intro_artist_color=#123456",
|
||||
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="#ffdf6b",
|
||||
help="Optional: Font color for intro video title text (default: #ffdf6b). Example: --intro_title_color=#123456",
|
||||
default="#ffffff",
|
||||
help="Optional: Font color for intro video title text (default: #ffffff). Example: --intro_title_color=#123456",
|
||||
)
|
||||
|
||||
args = parser.parse_args()
|
||||
@@ -135,8 +135,10 @@ def main():
|
||||
if len(args.args) > 2:
|
||||
artist = args.args[1]
|
||||
title = args.args[2]
|
||||
elif len(args.args) > 1:
|
||||
artist = args.args[1]
|
||||
else:
|
||||
logger.warn("URL provided without Artist and Title, these will be guessed from YouTube Title")
|
||||
logger.warn("URL provided without Artist and Title, both will be guessed from YouTube Title")
|
||||
|
||||
elif len(args.args) > 1:
|
||||
artist = args.args[0]
|
||||
@@ -184,6 +186,7 @@ def main():
|
||||
logger.info(f" YouTube Audio: {track['youtube_audio']}")
|
||||
logger.info(f" YouTube Still Image: {track['youtube_still_image']}")
|
||||
logger.info(f" Lyrics: {track['lyrics']}")
|
||||
logger.info(f" Processed Lyrics: {track['processed_lyrics']}")
|
||||
logger.info(f" Instrumental: {track['instrumental_audio']}")
|
||||
logger.info(f" Vocals: {track['vocals_audio']}")
|
||||
|
||||
Reference in new issue
Block a user