Closed JonasVautherin closed 1 year ago
Feels like it may be related to CORS on the server side. According to the Chromecast docs:
For adaptive media streaming, Google Cast requires the presence of CORS headers, but even simple mp4 media streams require CORS if they include Tracks. If you want to enable Tracks for any media, you must enable CORS for both your track streams and your media streams. So, if you do not have CORS headers available for your simple mp4 media on your server, and you then add a simple subtitle track, you will not be able to stream your media unless you update your server to include the appropriate CORS headers.
You need the following headers: Content-Type,Accept-Encoding, and Range. Note that the last two headers, Accept-Encoding and Range, are additional headers that you may not have needed previously.
Wildcards "*" cannot be used for the Access-Control-Allow-Origin header. If the page has protected media content, it must use a domain instead of a wildcard.
For my local video, I try to serve with:
#!/usr/bin/env python3
# It's python3 -m http.server PORT for a CORS world
from http.server import HTTPServer, SimpleHTTPRequestHandler
import sys
class CORSRequestHandler(SimpleHTTPRequestHandler):
def end_headers(self):
self.send_header('Access-Control-Allow-Origin', '*')
self.send_header('Access-Control-Allow-Methods', '*')
self.send_header('Access-Control-Allow-Headers', '*')
self.send_header('Cache-Control', 'no-store, no-cache, must-revalidate')
self.send_header('Content-Type', 'text/plain charset=UTF-8')
self.send_header('Accept-Encoding', '*')
self.send_header('Range', 0)
return super(CORSRequestHandler, self).end_headers()
def do_OPTIONS(self):
self.send_response(200)
self.end_headers()
host = sys.argv[1] if len(sys.argv) > 2 else '0.0.0.0'
port = int(sys.argv[len(sys.argv)-1]) if len(sys.argv) > 1 else 8080
print("Listening on {}:{}".format(host, port))
httpd = HTTPServer((host, port), CORSRequestHandler)
httpd.serve_forever()
But I'm certain that my Range
header is wrong, and I am not sure of the others. Also I don't know what to put in Access-Control-Allow-Origin
instead of *
.
Any idea there?
Probably not related to pychromecast anyway.
Probably not related to pychromecast anyway.
Did you find a solution to make HLS m3u8 without CORS work with pyChromecast?
For some reason I fail to play HLS on my Chromecast. I'm following the pychromecast readme until this point:
Which fails, but I don't know why (and pychromecast does not show any log, right?).
However the URL works with, e.g.
mpv
:I also tried creating an HLS (m3u8) setup locally with two other videos. For the first one, checking one of the
*.ts
chunks withffmpeg -i
, I see:For another video that I converted the same way:
Am I missing something?