diff --git a/app.py b/app.py index 0711e5fc..6890a3ad 100644 --- a/app.py +++ b/app.py @@ -764,6 +764,13 @@ def get_default_dl_dir(platform): default=None, required=False, ), + parser.add_argument( + "-m", + "--ffmpeg-url", + help="Override the ffmpeg address with a supplied URL.", + default=None, + required=False, + ), parser.add_argument( "--hide-overlay", action="store_true", @@ -823,6 +830,7 @@ def get_default_dl_dir(platform): hide_overlay=args.hide_overlay, screensaver_timeout=args.screensaver_timeout, url=args.url, + ffmpeg_url=args.ffmpeg_url, prefer_hostname=args.prefer_hostname ) diff --git a/karaoke.py b/karaoke.py index b88f69e9..7816c333 100644 --- a/karaoke.py +++ b/karaoke.py @@ -75,6 +75,7 @@ def __init__( hide_overlay=False, screensaver_timeout = 300, url=None, + ffmpeg_url=None, prefer_hostname=True ): @@ -151,6 +152,10 @@ def __init__( else: self.url = f"http://{self.ip}:{self.port}" self.url_parsed = urlparse(self.url) + if ffmpeg_url is None: + self.ffmpeg_url = f"{self.url_parsed.scheme}://{self.url_parsed.hostname}:{self.ffmpeg_port}" + else: + self.ffmpeg_url = ffmpeg_url # get songs from download_path self.get_available_songs() @@ -360,7 +365,7 @@ def get_youtube_id_from_url(self, url): def play_file(self, file_path, semitones=0): logging.info(f"Playing file: {file_path} transposed {semitones} semitones") stream_uid = int(time.time()) - stream_url = f"{self.url_parsed.scheme}://{self.url_parsed.hostname}:{self.ffmpeg_port}/{stream_uid}" + stream_url = f"{self.ffmpeg_url}/{stream_uid}" # pass a 0.0.0.0 IP to ffmpeg which will work for both hostnames and direct IP access ffmpeg_url = f"http://0.0.0.0:{self.ffmpeg_port}/{stream_uid}"