Go
Not registered? Sign up!

Can I stream an FLV file from an external URL?

Google Translate
27 posts | return to the Modules forum | get the rss feed for this thread

Oct. 18, 2008John

Hey everyone,

I'm using the JW FLV Player on my blog to embed FLV videos from other sites. Assuming I have the full http path to the FLV file, is it then possible to stream the file so that my readers can skip ahead in the video without having to wait for it to pre-load?

I've read the article on the site about HTTP Video streaming using the XMoov-PHP script (http://www.jeroenwijering.com/?item=HTTP_Video_Streaming), but it only offers information about streaming video files that are hosted locally on your own server, where as I need to stream files that are located on an external server.

Any help will be greatly appreciated!

Thanks for reading!

John

Oct. 18, 2008kLink

You can only stream the files from an external server, if that external server is a streaming server, either "fake" with scripts, lightTPD, or RTMP (FMS, Wowza, or Red5).

Oct. 19, 2008zupdaa

Let say I have a server X and server Y

Server X is only used to host videofiles (http://www.serverX.com/video.flv)
Server Y is the webserver / streaming server with lighttpd or php-scripts

Is it possible for visitors on Server Y to watch videos (http://www.serverX.com/video.flv)? No?

Oct. 19, 2008kLink

 
@zupdaa,

Theoretically, Server Y could request the video file from Server X and then stream it to the client.

There would be double traffic generated. From Server X to Server Y and then from Server Y to the client.

If Server X was only HTTP, you could use the HTTP v1.1 content range headers to seek into the file and request a portion of the file:Content-Range: bytes 21010-47021/47022

Oct. 21, 2008sclsama

- <trackList>
- <track>
<title>Title</title>
<location>http://http://www.elabonga.com/videos/Player/Movie.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-6-13</title>
<location>http://www.songs6.gigies.com/7hour/7h2008-6-13.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-6-12</title>
<location>http://www.songs6.gigies.com/7hour/7h2008-6-12.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-6-11</title>
<location>http://www.songs6.gigies.com/7hour/7hour2008-6-12.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-5-16</title>
<location>http://www.songs6.gigies.com/7hour/7hour1.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-5-16</title>
<location>http://www.songs6.gigies.com/7hour/7hour2.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-5-13</title>
<location>http://www.songs6.gigies.com/7hour/7 hour-1.flv</location>
<meta rel="type">flv</meta>
</track>
</trackList>
</playlist>

Oct. 21, 2008sclsama

- <trackList>
- <track>
<title>Title</title>
<location>http://http://www.elabonga.com/videos/Player/Movie.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-6-13</title>
<location>http://www.songs6.gigies.com/7hour/7h2008-6-13.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-6-12</title>
<location>http://www.songs6.gigies.com/7hour/7h2008-6-12.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-6-11</title>
<location>http://www.songs6.gigies.com/7hour/7hour2008-6-12.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-5-16</title>
<location>http://www.songs6.gigies.com/7hour/7hour1.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-5-16</title>
<location>http://www.songs6.gigies.com/7hour/7hour2.flv</location>
<meta rel="type">flv</meta>
</track>
- <track>
<title>2008-5-13</title>
<location>http://www.songs6.gigies.com/7hour/7 hour-1.flv</location>
<meta rel="type">flv</meta>
</track>
</trackList>
</playlist>

Oct. 21, 2008jkhkjkjkjkj

http://www.sivasspor.com

Oct. 29, 2008John

Ok, but the question is how do I do that? If I'm embedding an FLV file from a server that supports steaming, i.e. it's a site that has streaming in it (such as YouTube), how do I access that site's streaming functions and duplicate them on the JW player on my site?

The thing is that I can just use their embed code and embed their player and then I will have streaming enabled, but I want to embed the flv movie via JW player, so how do I enable streaming that way?

Oct. 29, 2008kLink

YouTube is the only major video site that has an API. If you use the JW FLV Media Player to play YouTube videos through the YouTube API, the scrubbing might work (I haven't tried it recently). For the other sites, you have to use their player or figure out how it works to scrub. Most of them don't want people leeching their content and generating traffic costs for which they receive no revenue.

Mar. 01, 2009Skndr

also i have same problem
"Can I stream an FLV file from an external URL? "

in my dedicated server i use apache + lighttpd, my website run in apache , flv videos hosted in lighttpd

how i can let xmoov-php to call flv from lighttpd "sub domain + other port"

flv video hosted in >> http://mywebsite.com:81/uploads/
web site run in >> http://mywebsite.com


Any help will be greatly appreciated

Mar. 01, 2009lefTy

If you already have LightTPD for streaming the videos, then don't use the xmoov script at all.

Just hand the video off to LightTPD from your PHP script on Apache using the X-LIGHTTPD-send-file header, like this:
header("X-LIGHTTPD-send-file: /path/to/video/files/" . $file);

Adjust the path to your videos. Use a 302 Redirect if LightTPD is on a different IP address.

(Works better using nginx with the flv and h264 streaming modules and FastCGI for the PHP.)

Mar. 01, 2009Skndr

sorry lefTy can you explain more please wink
where i can post this code

header("X-LIGHTTPD-send-file: /path/to/video/files/" .
$file);

and thanx alot for replay

Mar. 01, 2009Skndr

i want to use xmoov-php to disable resume download,
and set 1 connection in download manager per IP,

I know i can do that with lighttpd but its more easy with xmoov-php

Mar. 01, 2009lefTy

I don't have tested code for handing off from Apache PHP to LightTPD for the video streaming

Here's how I do it on nginx and LightTPD with the PHP being executed by a FastCGI server.

The only thing that is different between nginx and LightTPD is the X-Accel-Redirect vs. the X-Sendfile header.

<?php

// for testing call with:              http://www.mydomain.com/path/down.php?start=123456&file=video&token=ABC123&crap=flv
// for the JWMP use: 'streamer',      'http://www.mydomain.com/path/down.php');
//                   'file',           encodeURIComponent('video&token=ABC123&crap=flv'));

$file   = isset($_GET['file'])  ? strval($_GET['file'])  : 'video.flv';
$start  = isset($_GET['start']) ? intval($_GET['start']) :           0;
$token  = isset($_GET['token']) ? strval($_GET['token']) :          '';
$file   = $file . ".flv";

//print "File: " . $file . "<br />Start: " . $start . "<br />Token: " . $token; exit;

//...perform any required security checks, validation and/or stats accounting

//...logging
$filename = 'down.log';

//...check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);

//...log file format
$datetime    = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER['REMOTE_ADDR'] . "  " . $datetime . "  " . $file . "  " . $start . "  " . $token . "\r\n";

//...open $filename for append.
$handle = fopen($filename, 'a') or die("Could not open file: " . $filename . "\n");

//...write $somecontent to the open file.
fwrite($handle, $somecontent) or die("Could not write to file: " . $filename . "\n");

fclose($handle);

//...redirect user to internal location - LightTPD
//header("X-Sendfile: \path\from\filesystem\root\\" . $file . "?start=" . $start);

//...redirect user to internal location - nginx
header("X-Accel-Redirect: /Movies/" . $file . "?start=" . $start);

?>


Some useful links:

      http://blog.lighttpd.net/articles/2006/07/02/x-sendfile

      http://redmine.lighttpd.net/wiki/lighttpd/HowToFightDeepLinking

      http://redmine.lighttpd.net/projects/lighttpd/wiki/X-LIGHTTPD-send-file

      http://blog.thinkphp.de/archives/136-Make-the-download-of-large-files-with-PHP-and-lighty-very-easy.html

Mar. 06, 2009PLC

is there a way to patch/modify the mod_flv_streaming for it to open a remote file ? That would be 'much' easier ? No ?

Mar. 06, 2009lefTy

If you only want to access an external file, that is just some server configuration.

The purpose of the script posted above is to do authentication, logging, stats accounting, etc, on the FastCGI server, then hand the video streaming back to nginx or LightTPD using the FLV and/or H.264 streaming modules, which also provide seeking into the video file so the player's scrubber can seek ahead of the download in a large video file.

Mar. 08, 2009PLC

@Lefty :
If you only want to access an external file, that is just some server configuration.

What do you mean by server config ? I don't think lighttpd can stream files that aren't on the host itself.

Mar. 08, 2009lefTy

Depending on how "external" you want to go, you can specify an external location on a Network File System (NFS) using an X-Sendfile header or you can specify a an external host by IP address using mod_proxy (mod_magnet in v1.5).

Bear in mind that the stream will pass through the origin server (doubling the traffic) unless you use a redirect to the external server, then you lose control of the stream though.

Apr. 18, 2009Bock

i Know a way i use to love doing this over and over until they changed it the site was clipnabber.com and they allowed you to put the link of youtube into it press get video button and in a few seconds get the full real .flv url of the video they found a cheaper way of doing it now and it sucks

Sep. 30, 2009help

How do I use embed code with this script?

<?php

// for testing call with: http://www.mydomain.com/path/down.php?start=123456&file=video&token=ABC123&crap=flv
// for the JWMP use: 'streamer', 'http://www.mydomain.com/path/down.php');
// 'file', encodeURIComponent('video&token=ABC123&crap=flv'));

$file = isset($_GET['file']) ? strval($_GET['file']) : 'video.flv';
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$token = isset($_GET['token']) ? strval($_GET['token']) : '';
$file = $file . ".flv";

//print "File: " . $file . "<br />Start: " . $start . "<br />Token: " . $token; exit;

//...perform any required security checks, validation and/or stats accounting

//...logging
$filename = 'down.log';

//...check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);

//...log file format
$datetime = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER['REMOTE_ADDR'] . " " . $datetime . " " . $file . " " . $start . " " . $token . "\r\n";

//...open $filename for append.
$handle = fopen($filename, 'a') or die("Could not open file: " . $filename . "\n");

//...write $somecontent to the open file.
fwrite($handle, $somecontent) or die("Could not write to file: " . $filename . "\n");

fclose($handle);

//...redirect user to internal location - LightTPD
//header("X-Sendfile: \path\from\filesystem\root\\" . $file . "?start=" . $start);

//...redirect user to internal location - nginx
header("X-Accel-Redirect: /Movies/" . $file . "?start=" . $start);

?>

Sep. 30, 2009lost

 
See the comments at the top of the code.

JWMP = JW Media Player

The correct streamer and file flashvars are shown in the comments.

Oct. 01, 2009help

lost, thank you, but I still don't understand, can you show me an example.

Thank you

Oct. 01, 2009help

<?php

<embed src="http://www.domain.com/embed/cinemaplayer.swf" name="sonetticFLVPlayer" type="application/x-shockwave-flash" bgcolor="#000000" allowfullscreen="true" flashvars="content=http://cache01-videos02.myspacecdn.com/131/vid_5a669af790964c7f975ef20f6d605204.flv" width="500" height="350"></embed>
'http://cache01-videos02.myspacecdn.com/131/vid_5a669af790964c7f975ef20f6d605204.flv',encodeURIComponent('video&token=ABC123&crap=flv'));

$file = isset($_GET['file']) ? strval($_GET['file']) : 'video.flv';
$start = isset($_GET['start']) ? intval($_GET['start']) : 0;
$token = isset($_GET['token']) ? strval($_GET['token']) : '';
$file = $file . ".flv";

//print "File: " . $file . "<br />Start: " . $start . "<br />Token: " . $token; exit;

//...perform any required security checks, validation and/or stats accounting

//...logging
$filename = 'down.log';

//...check to see if $filename exists, if not, create it.
touch($filename) or die("Unable to create: " . $filename);

//...log file format
$datetime = "[" . date('d/M/Y:h:i:s O') . "]";
$somecontent = $_SERVER['REMOTE_ADDR'] . " " . $datetime . " " . $file . " " . $start . " " . $token . "\r\n";

//...open $filename for append.
$handle = fopen($filename, 'a') or die("Could not open file: " . $filename . "\n");

//...write $somecontent to the open file.
fwrite($handle, $somecontent) or die("Could not write to file: " . $filename . "\n");

fclose($handle);

//...redirect user to internal location - LightTPD
//header("X-Sendfile: \path\from\filesystem\root\\" . $file . "?start=" . $start);

//...redirect user to internal location - nginx
header("X-Accel-Redirect: /Movies/" . $file . "?start=" . $start);

?>

Oct. 01, 2009lost

 
Your embed code should NOT be placed in the PHP script.

The embed code should be placed in the HTML document where you want to embed your Flash content.

You are requesting the FLV video file from myspacecdn which probably isn't setup to accept this type of request.

The down.php script is intended to be used on your own nginx server.

Oct. 01, 2009help

can you show me please what di i need in that script.

I will be using www.intv.ru, they run nginx server

Oct. 01, 2009lost

 
You would have to place the down.php script on www.intv.ru's server before it would work. Will they allow you to do that?

Oct. 05, 2009help

is there any way to embed files like this

http://kinobanda.ru/video/6382/1/0/662a8e65156e4b545a5271bd55b2e0c8/video.flv

intv.ru does the same

Add a reaction

You can also return to the category or try this search for related threads.


 

Search the Forums

Go

Support

Support Here are some helpful links to learn more about the JW Player™:

Monetize Your Video

Monetize Your Video Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!

Why Buy a License?

Why Buy a License? If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.