Well, although not the most direct, you can try this.
First configure .htaccess to transparently capture all .ogv videos and process them using PHP
.htaccess
RewriteEngine On
RewriteRule ^(.*)\.ogv$ ogv.php?file=$1
ogv.php
<?php
$file = $_GET['file'] . '.ogv';
while ( strpos($file, '..') !== false )
{
$file = str_replace('..', '', $file);
}
$filesize = filesize($file);
header("Content-Type: video/ogg");
header("Content-Transfer-Encoding: binary");
header("Content-Length: {$filesize}");
readfile($file);
exit()
?>
HTML:
<video src="video.ogv" id="video" controls></video>
<script>
var video_src = document.getElementById('video').src;
var xhr = new XMLHttpRequest();
xhr.open('GET', video_src, false);
xhr.send(null);
var size = xhr.getResponseHeader('Content-Length');
alert(size);
</script>
So how does this system work. Just bind the video in .ogv format, as usual, but the .htaccess file first captures the request and sends it to ogv.php. Then the PHP file sends a file size header if the server is not working automatically. Alright, that still doesn't do you much good, right? So, you can make an Ajax request for the video and extract the file from the HTTP headers.
Hope this helps.
source
share