You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

How to use PHP as source of video stream? Created Oct 24, 2009

This thread is solved

Views: 929     Replies: 6     Last reply Nov 18, 2009  
You must login first before you can use this feature

jet7

Posts: 6

Registered:
Oct 24, 2009

How to use PHP as source of video stream?

Posted: Oct 24, 2009

How to get this to work with flowplayer:

---------------------


...

<a href="fp_testi.php"  style="display:block;width:320px;height:250px" id="player"></a>  
				  
  <script type="text/javascript">
							
      flowplayer("player", "flowplayer-3.1.4.swf", { 
											clip:  { 
												autoPlay: true, 
												autoBuffering: false,
												fullscreenOnly: false,
												bufferLength: 25
											}
											
		}); 

</script>
				  
  

...
---------------------

<?php 

// fp_testi.php:

$lh = "video.flv";
$fp = fopen($lh, 'rb');
		
      header("Content-Type: video/x-flv");
      header("Content-Length: " . filesize($lh));
      
      fpassthru($fp);
			
fclose($fp);

?>


The problem is that it gives error 200, stream not found

gmccomb

Posts: 667

Registered:
Apr 9, 2009

» How to use PHP as source of video stream?

Posted: Oct 24, 2009

Reply to: How to use PHP as source of video stream?, from jet7
Flowplayer wants a URL, not a file. Research methods of having PHP dump the file to a temporary URL, and give that URL to Flowplayer.

jet7

Posts: 6

Registered:
Oct 24, 2009

» » How to use PHP as source of video stream?

Posted: Oct 25, 2009

Reply to: » How to use PHP as source of video stream?, from gmccomb
Thank you! :)

JSM

Posts: 6

Registered:
May 24, 2009

» » » How to use PHP as source of video stream?

Posted: Nov 13, 2009

Reply to: » » How to use PHP as source of video stream?, from jet7
The url to your php script is the thing to give flowplayer - it uses that to try getting the raw video data.

That php script should spit out the raw video data.

The following should work where $video_file_path is the path to your video on your server (header assuming it's an mp4 or so below...):

header("Content-Type: video/mpeg");
header('Content-Length: '.filesize($video_file_path));
@readfile($video_file_path);

Hope this helps!

jb123

Posts: 31

Registered:
Oct 16, 2009

» » » » How to use PHP as source of video stream?

Posted: Nov 15, 2009

Reply to: » » » How to use PHP as source of video stream?, from JSM
jet7,

Here's an additional example. It's a minimal example I quickly copy/pasted from my working application that shows how to pass one or more params to Flowplayer and then pass that param to .php and have .php return your video URL to Flowplayer.

I cut and pasted pretty quickly and removed code not needed for this minimal example and I added comments for you.

HTH,

-JB


//play.php
<?php	// retrieve passed in querystring param
	$vid = (isset($_GET['vid']))? $_GET['vid'] : '';
	
	//do something here with the param you passed to return the full video URL to Flowplayer
	//i.e., you may have your video metadata stored in a database, xml file, etc...
	
	header("Location: $videourl");
?>

function playVideo(myVideoUrl) {
				//wmode setting is not relevant to passing params
	flowplayer("player", {src: 'https://www.example/flowplayer.commercial-3.1.5.swf', wmode: 'opaque'}, 
		
			clip: {
				autoPlay: true,		// this setting is not relevant to passing params
				autoBuffering: true,	// this setting is not relevant to passing params

				//optionally, for greater security construct the baseURL in your .php file
				baseUrl: 'https://www.example.com/phppages/',

				//this is the relevant line that indicates
				//how to pass 1 param to flowplayer with JavaScript
				//note that querystring must be escaped

				//hard coded param
				url: escape('play.php?vid=100'),

				//or use dynamic javascript param
				url: escape('play.php?vid=' + myVideoUrl),

				//how to pass in multiple params
				//url: escape('play.php?vid=' + myVideoUrl + '¶mName2=' + paramvalue2),

				scaling: 'scale' /this setting is not releveant to passing params											
			}
		}
	);
}

jb123

Posts: 31

Registered:
Oct 16, 2009

» » » » » How to use PHP as source of video stream?

Posted: Nov 15, 2009

Reply to: » » » » How to use PHP as source of video stream?, from jb123
Odd, for some reason this line the ampersand and param name was mangled in my 1st email.

It should be..
//how to pass in multiple params //url: escape('play.php?vid=' + myVideoUrl + '¶,Name2=' + paramvalue2),

Hoepefully, it won't get mangled this time.

-JB

jet7

Posts: 6

Registered:
Oct 24, 2009

» » » » » » How to use PHP as source of video stream?

Posted: Nov 18, 2009

Reply to: » » » » » How to use PHP as source of video stream?, from jb123
Thanks guys!

Got it working! :)

Jesus is the Lord. Amen.