I have a PHP script for stream a video from an url, and I want to get the time to control the flow.
Browsers makes HTTP requests with a range of bytes when jumping at a time of the video.
Request Headers
Accept:*/ *
Accept-Encoding:identity;q=1, *;q=0
Accept-Language:fr-FR,fr;q=0.8,en-US;q=0.6,en;q=0.4
Connection:keep-alive
Host:h.com
If-Range:Tue, 20 Oct 2015 23:38:00 GMT
Range:bytes=560855038-583155711
Referer:http://h.com/7743a76d2911cdd90354bc42be302c6946c6e5b4
User-Agent:Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/49.0.2623.75 Safari/537.36
Response Headers
Accept-Ranges:bytes
Cache-Control:private, max-age=14400
Connection:Keep-Alive
Content-Length:22300674
Content-Range:bytes 560855038-583155711/605162520
Content-Type:video/mp4
Date:Tue, 10 May 2016 11:23:34 GMT
Expires:Tue, 10 05 2016 15:23:34 GMT
Keep-Alive:timeout=5, max=98
Last-Modified:Tue, 20 Oct 2015 23:38:00 GMT
Server:Apache/2.4.7 (Ubuntu)
X-Powered-By:PHP/5.5.9-1ubuntu4.16
How works that time to bytes conversion ?
On my PHP server I try to get the time from the byte request :
$time_second = $start_request_byte / $video_size_byte * $video_length_second;
But it's not the solution, it isn't exact... Any ideas ?
Thanks
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…