How to watch Geo locked video streams
#1
I recently started to develop a plugin for ABC Australia podcasts. Being an australian living in Canada i wanted to be able to watch some australian content but unfortunately many of the streams are geo locked and cannot be played outside australia. To get around this problem i first checked out proxy servers but this seemed unnecessarily expensive and quite often slow(if it's free).

I decided to create a different solution to the problem. I got a cheap hosting account with an australian ip and wrote a php script to make the stream work from outside australia. The idea is this, your cheap hosting makes the request to the geo locked stream and then real time streams it from your new ip address.

the usage is as follows:

if inside australia you would use the following url for example:
http://the_geolocked_stream/filename.mp4

after installing my script on your server you would use a url like this:

http://your_cheap_domain/stream.php?mp4=...lename.mp4

this will allow you to access the stream from any country.

*Note: at the moment the script only works with mp4's and does not allow seeking while playing.

Theoretically this idea will work for any country so if you want to test it let me know how it goes.

To set it up just put the following code in a file called stream.php on your server.

<?php
header("HTTP/1.1 200 OK");
header("Date: Tue, 19 May 2009 20:55:26 GMT");
header("Server: Apache/2.2.3 (Debian) mod_mono/1.2.1 mod_python/3.2.10 Python/2.4.4 PHP/5.2.9-0.dotdeb.1 with Suhosin-Patch mod_ssl/2.2.3 OpenSSL/0.9.8c mod_perl/2.0.2 Perl/v5.8.8");
header("Last-Modified: Tue, 19 May 2009 20:50:33 GMT");
header("ETag: \"5696da-54ac4-fdb5840\"");
header("Accept-Ranges: bytes");
header("Content-Length: ".get_remote_file_size($_GET["mp4"]));
header("Content-Type: video/mp4");

passthru("wget ".$_GET["mp4"]." -O-");

function get_remote_file_size($url, $readable = true)
{
$parsed = parse_url($url);
$host = $parsed["host"];
$fp = @fsockopen($host, 80, $errno, $errstr, 20);
if(!$fp) return false;
else
{
@fputs($fp, "HEAD $url HTTP/1.1\r\n");
@fputs($fp, "HOST: $host\r\n");
@fputs($fp, "Connection: close\r\n\r\n");
$headers = "";
while(!@feof($fp))$headers .= @fgets ($fp, 128);
}
@fclose ($fp);
$return = false;
$arr_headers = explode("\n", $headers);
foreach($arr_headers as $header)
{
// follow redirect
$s = 'Location: ';
if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s))
{
$url = trim(substr($header, strlen($s)));
return get_remote_file_size($url, $readable);
}

// parse for content length
$s = "Content-Length: ";
if(substr(strtolower ($header), 0, strlen($s)) == strtolower($s))
{
$return = trim(substr($header, strlen($s)));
break;
}
}
return $return;
}
?>
Reply
#2
In other words you've written your own proxy server ;-)

JR
Reply
#3
jhsrennie Wrote:In other words you've written your own proxy server ;-)

JR

Basically, yeah. The hosting only costs me $2.25AUD per month with unlimited transfer so it is a lot cheaper than most of the decent proxies out there.
Reply

Logout Mark Read Team Forum Stats Members Help
How to watch Geo locked video streams0