I'm trying to serve a file via php, with the following PHP code:
header("Accept-Ranges: bytes");
header("Access-Control-Allow-Origin: *");
header("Cache-Control: no-cache, must-revalidate");
header('Content-Type: application/vnd.apple.mpegurl');
echo file_get_contents('path/to/file.m3u8');
This seems to work:
root@server:~curl -I -XGET http://example.com/path/to/file.php
HTTP/1.1 200 OK
Server: nginx/1.22.1
Date: Sat, 04 Feb 2023 15:23:41 GMT
Content-Type: application/vnd.apple.mpegurl
Transfer-Encoding: chunked
Connection: keep-alive
X-Powered-By: PHP/8.1.14
Accept-Ranges: bytes
Access-Control-Allow-Origin: *
Cache-Control: no-cache, must-revalidate
However when I put http://example.com/path/to/file.php
in VLC, it does not play the video.
Here are the ???:
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-STREAM-INF:BANDWIDTH=3794805,RESOLUTION=1920x1080,CODECS="avc1.4d4028,mp4a.40.2"
https://another-domain/1080p/chunks.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1866000,RESOLUTION=1280x720,CODECS="avc1.4d401f,mp4a.40.2"
https://another-domain/720p/chunks.m3u8
#EXT-X-STREAM-INF:BANDWIDTH=1054041,RESOLUTION=854x480,CODECS="avc1.77.30,mp4a.40.2"
https://another-domain/480p/chunks.m3u8
I'm not sure what the problem is. What do I need to do to be able to serve this file with PHP?