Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

Can I stream an FLV file from an external URL?


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

27 Community Answers

JW Player

User  
-1 rated :

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).

JW Player

User  
0 rated :

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?

JW Player

User  
0 rated :


@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:bc.. Content-Range: bytes 21010-47021/47022

JW Player

User  
0 rated :

- <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>

JW Player

User  
0 rated :

- <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>

JW Player

User  
0 rated :

http://www.sivasspor.com

JW Player

User  
0 rated :

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?

JW Player

User  
0 rated :

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.

JW Player

User  
0 rated :

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

JW Player

User  
0 rated :

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:bc.. 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.)

JW Player

User  
0 rated :

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

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

and thanx alot for replay

JW Player

User  
0 rated :

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

JW Player

User  
0 rated :

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*.
bc.. <?php

//fortestingcallwith:http://www.mydomain.com/path/down.php?start=123456&file=video&token=ABC123&crap=flv
//fortheJWMPuse:'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;

//...performanyrequiredsecuritychecks,validationand/orstatsaccounting

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

//...checktoseeif$filenameexists,ifnot,createit.
touch($filename)ordie("Unabletocreate:".$filename);

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

//...open$filenameforappend.
$handle=fopen($filename,'a')ordie("Couldnotopenfile:".$filename."\n");

//...write$somecontenttotheopenfile.
fwrite($handle,$somecontent)ordie("Couldnotwritetofile:".$filename."\n");

fclose($handle);

//...redirectusertointernallocation-LightTPD
//header("X-Sendfile:\path\from\filesystem\root\\".$file."?start=".$start);

//...redirectusertointernallocation-nginx
header("X-Accel-Redirect:/Movies/".$file."?start=".$start);

?>



Someusefullinks:

*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*

JW Player

User  
0 rated :

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

JW Player

User  
0 rated :

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.

JW Player

User  
0 rated :

@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.

JW Player

User  
0 rated :

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.

JW Player

User  
0 rated :

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

JW Player

User  
0 rated :

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);

?>


JW Player

User  
0 rated :


See the comments at the top of the code.

JWMP = JW Media Player

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

JW Player

User  
0 rated :

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

Thank you

JW Player

User  
0 rated :

<?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);

?>

JW Player

User  
0 rated :


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.

JW Player

User  
0 rated :

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

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

JW Player

User  
0 rated :


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?

JW Player

User  
0 rated :

is there any way to embed files like this

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

intv.ru does the same

JW Player

User  
0 rated :

is possible to re-stream something from a remote place with
x-sendfile or mod_flv_streaming ?

for example:

header("X-Sendfile: http://otherdomain.com/videos/funny.flv");

This question has received the maximum number of answers.