Skip to content

Commit

Permalink
feat: support splash screen background video (#464)
Browse files Browse the repository at this point in the history
Todo:
- [x] Add a default background loop video with reasonable file size
- [x] Allow disabling screensaver
- [x] Fix fade in after song transition not right
- [x] Black bar on top, fill stretch/cover/contain?
- [x] Sometimes video does not return from screensaver exit
  • Loading branch information
vicwomg committed Jan 8, 2025
1 parent b6182e0 commit 5774208
Show file tree
Hide file tree
Showing 18 changed files with 650 additions and 495 deletions.
1 change: 1 addition & 0 deletions pikaraoke/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ def main():
disable_bg_music=args.disable_bg_music,
bg_music_volume=args.bg_music_volume,
bg_music_path=args.bg_music_path,
bg_video_path=args.bg_video_path,
disable_score=args.disable_score,
limit_user_songs_by=args.limit_user_songs_by,
config_file_path=args.config_file_path,
Expand Down
2 changes: 1 addition & 1 deletion pikaraoke/babel.cfg
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[python: **.py]
[jinja2: **/templates/**.html]
extensions=jinja2.ext.autoescape,jinja2.ext.i18n
extensions=jinja2.ext.i18n
silent=False
5 changes: 5 additions & 0 deletions pikaraoke/karaoke.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class Karaoke:
loop_interval = 500 # in milliseconds
default_logo_path = os.path.join(base_path, "logo.png")
default_bg_music_path = os.path.join(base_path, "static/music/")
default_bg_video_path = os.path.join(base_path, "static/video/the_drive_by_visualdon.mp4")
screensaver_timeout = 300 # in seconds

ffmpeg_process = None
Expand Down Expand Up @@ -98,6 +99,8 @@ def __init__(
disable_bg_music=False,
bg_music_volume=0.3,
bg_music_path=None,
bg_video_path=None,
disable_bg_video=False,
disable_score=False,
limit_user_songs_by=0,
config_file_path="config.ini",
Expand Down Expand Up @@ -146,6 +149,8 @@ def __init__(
self.disable_bg_music = self.get_user_preference("disable_bg_music") or disable_bg_music
self.bg_music_volume = self.get_user_preference("bg_music_volume") or bg_music_volume
self.bg_music_path = self.default_bg_music_path if bg_music_path == None else bg_music_path
self.disable_bg_video = self.get_user_preference("disable_bg_video") or disable_bg_video
self.bg_video_path = self.default_bg_video_path if bg_video_path == None else bg_video_path
self.disable_score = self.get_user_preference("disable_score") or disable_score
self.limit_user_songs_by = (
self.get_user_preference("limit_user_songs_by") or limit_user_songs_by
Expand Down
23 changes: 21 additions & 2 deletions pikaraoke/lib/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def parse_volume(volume, type):
default_port = 5555
default_volume = 0.85
default_normalize_audio = False
default_splash_delay = 3
default_splash_delay = 2
default_screensaver_delay = 300
default_log_level = logging.INFO
default_prefer_hostname = False
Expand Down Expand Up @@ -95,7 +95,7 @@ def parse_pikaraoke_args():
parser.add_argument(
"-t",
"--screensaver-timeout",
help="Delay before the screensaver begins (in secs). (default: %s )"
help="Delay before the screensaver begins (in secs). Set to 0 to disable screensaver. (default: %s )"
% default_screensaver_delay,
default=default_screensaver_delay,
type=int,
Expand Down Expand Up @@ -207,6 +207,19 @@ def parse_pikaraoke_args():
default=None,
required=False,
),
parser.add_argument(
"--bg-video-path",
nargs="+",
help="Path to a background video mp4 file. Will play in the background of the splash screen.",
default=None,
required=False,
),
parser.add_argument(
"--disable-bg-video",
action="store_true",
help="Disable background video on splash screen",
required=False,
),
parser.add_argument(
"--disable-score",
help="Disable the score screen after each song",
Expand Down Expand Up @@ -238,13 +251,19 @@ def parse_pikaraoke_args():
youtubedl_path = arg_path_parse(args.youtubedl_path)
logo_path = arg_path_parse(args.logo_path)
bg_music_path = arg_path_parse(args.bg_music_path)
bg_video_path = arg_path_parse(args.bg_video_path)

if bg_video_path is not None and not os.path.isfile(bg_video_path):
print(f"Background video found: {bg_video_path}. Setting to None")

dl_path = os.path.expanduser(arg_path_parse(args.download_path))
if not dl_path.endswith("/"):
dl_path += "/"

args.youtubedl_path = youtubedl_path
args.logo_path = logo_path
args.bg_music_path = bg_music_path
args.bg_video_path = bg_video_path
args.download_path = dl_path

return args
Loading

0 comments on commit 5774208

Please sign in to comment.