Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

303 proxy http ffmpeg streams #304

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
Open

Conversation

vicwomg
Copy link
Owner

@vicwomg vicwomg commented Dec 28, 2023

#303 Proxies the ffmpeg port 5556 url to /stream/<stream_id>

Enables pikaraoke to run on a single port, which simplifies internet-hosted installations, and appears to fix Safari (OSX and IOS)

@redmeneses
Copy link

It worked perfectly for video files, but it can't play MP3+G.
[2023-12-28 05:33:41] INFO: 'teste' is adding song to queue: /mnt/karaoke/teste/Kiss - Rock & Roll All Nite [SC Karaoke].mp3
[2023-12-28 05:33:44] INFO: Playing file: /mnt/karaoke/teste/Kiss - Rock & Roll All Nite [SC Karaoke].mp3 transposed 0 semitones
/mnt/karaoke/teste
Kiss - Rock & Roll All Nite [SC Karaoke].cdg
[2023-12-28 05:33:44] INFO: Playing CDG/MP3 file: /mnt/karaoke/teste/Kiss - Rock & Roll All Nite [SC Karaoke].mp3
[2023-12-28 05:33:47] INFO: Song starting: Kiss - Rock & Roll All Nite [SC Karaoke]
[2023-12-28 05:33:55] INFO: Song ending: Kiss - Rock & Roll All Nite [SC Karaoke]
[2023-12-28 05:33:55] ERROR: Exception on /stream/1703741624 [GET]
Traceback (most recent call last):
File "/root/karaoke/.venv/lib/python3.11/site-packages/urllib3/response.py", line 712, in _error_catcher
yield
File "/root/karaoke/.venv/lib/python3.11/site-packages/urllib3/response.py", line 1071, in read_chunked
self._update_chunk_length()
File "/root/karaoke/.venv/lib/python3.11/site-packages/urllib3/response.py", line 1006, in _update_chunk_length
raise InvalidChunkLength(self, line) from None
urllib3.exceptions.InvalidChunkLength: InvalidChunkLength(got length b'', 0 bytes read)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/root/karaoke/.venv/lib/python3.11/site-packages/requests/models.py", line 816, in generate
yield from self.raw.stream(chunk_size, decode_content=True)
File "/root/karaoke/.venv/lib/python3.11/site-packages/urllib3/response.py", line 931, in stream
yield from self.read_chunked(amt, decode_content=decode_content)
File "/root/karaoke/.venv/lib/python3.11/site-packages/urllib3/response.py", line 1059, in read_chunked
with self._error_catcher():
File "/usr/lib/python3.11/contextlib.py", line 155, in exit
self.gen.throw(typ, value, traceback)
File "/root/karaoke/.venv/lib/python3.11/site-packages/urllib3/response.py", line 729, in _error_catcher
raise ProtocolError(f"Connection broken: {e!r}", e) from e
urllib3.exceptions.ProtocolError: ("Connection broken: InvalidChunkLength(got length b'', 0 bytes read)", InvalidChunkLength(got length b'', 0 bytes read))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/root/karaoke/.venv/lib/python3.11/site-packages/flask/app.py", line 2529, in wsgi_app
response = self.full_dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/karaoke/.venv/lib/python3.11/site-packages/flask/app.py", line 1825, in full_dispatch_request
rv = self.handle_user_exception(e)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/karaoke/.venv/lib/python3.11/site-packages/flask/app.py", line 1823, in full_dispatch_request
rv = self.dispatch_request()
^^^^^^^^^^^^^^^^^^^^^^^
File "/root/karaoke/.venv/lib/python3.11/site-packages/flask/app.py", line 1799, in dispatch_request
return self.ensure_sync(self.view_functions[rule.endpoint])(**view_args)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/karaoke/app.py", line 615, in redirect_to_ffmpeg_stream
res = requests.request( # ref. https://stackoverflow.com/a/36601467/248616
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/karaoke/.venv/lib/python3.11/site-packages/requests/api.py", line 59, in request
return session.request(method=method, url=url, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/karaoke/.venv/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
resp = self.send(prep, **send_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/root/karaoke/.venv/lib/python3.11/site-packages/requests/sessions.py", line 747, in send
r.content
File "/root/karaoke/.venv/lib/python3.11/site-packages/requests/models.py", line 899, in content
self._content = b"".join(self.

@vicwomg
Copy link
Owner Author

vicwomg commented Dec 28, 2023

@redmeneses mp3+cdg seems to work fine for me. Both zipped archives and separate files. have you tried other example files? Wondering if there's an issue with this particular one

@honestlai
Copy link

Discovered a few things last night running this on my iPad and iPhone

  1. In Safari I had to touch the screen just before or during the first stream was about to play, otherwise the splash page would just skip to the next song, and then skip again.

  2. Not a biggie, but I noticed on my phone, the karaoke video ends up taking over and going full screen in front of the css overlays.

  3. In Chrome on my iPad, the splash page didn't require interaction like Safari above, but the streams would play for 2 or 3 seconds, and then immediately switch to the next song. This behavior continues until the queue is empty. I actually experienced this on Chrome on my Firestick as well.

@vicwomg
Copy link
Owner Author

vicwomg commented Dec 29, 2023

  1. In Chrome on my iPad, the splash page didn't require interaction like Safari above, but the streams would play for 2 or 3 seconds, and then immediately switch to the next song. This behavior continues until the queue is empty. I actually experienced this on Chrome on my Firestick as well.

Very strange, I'm seeing this behavior too now, but when I first tried it worked just fine. I'm unsure what may have changed. Will look in to it but if it burns too much time, I might just merge this treat the iOS stuff as a separate issue from the single-port optimization.

@vicwomg
Copy link
Owner Author

vicwomg commented Dec 29, 2023

  1. Not a biggie, but I noticed on my phone, the karaoke video ends up taking over and going full screen in front of the css overlays.

I could not reproduce this one. My guess is you're using your own branch and its missing the <video playsinline> change which might explain that behavior. I believe mobile safari likes to pop open the iOS native video player unless playsinline is specified

@honestlai
Copy link

Ya, I agree... playing over iPad is more of a nice-to-have. I think for most people, they'll either have a Raspberry Pi connected to their TV for this or a laptop.

What I was really hoping to do was make it so I could get this running on my Firestick, since they're android based and many folks already have android based devices or smart TV's already.

I might try to code a wrapper app that would accomplish this that could connect to either a local host or internet facing host. It would be pretty cool to be able to have this available for SmartTVs or Streamers like Fire Sticks

@frankchau93
Copy link

Ya, I agree... playing over iPad is more of a nice-to-have. I think for most people, they'll either have a Raspberry Pi connected to their TV for this or a laptop.

What I was really hoping to do was make it so I could get this running on my Firestick, since they're android based and many folks already have android based devices or smart TV's already.

I might try to code a wrapper app that would accomplish this that could connect to either a local host or internet facing host. It would be pretty cool to be able to have this available for SmartTVs or Streamers like Fire Sticks

I use Kiosk Full Screen Browser to accomplish what you're looking for if you're using Android TV. If you do code a wrapper please share how you did it!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants