9 Replies - 25580 Views - Last Post: 28 September 2011 - 07:14 AM Rate Topic: -----

#1 macb6497  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 80
  • Joined: 25-December 09

Create your own live stream server without RED5

Posted 09 July 2011 - 02:00 PM

Hello Everyone!

I'm here to help those who have tried to create their own live server, whether it be for only audio or both audio and video.

When I say live server I mean exactly like Ustream.tv or livestream except it is exactly the way YOU want it. I.E. without all the advertisements, bandwidth limits, watermarks (Ustream), and spam.

You can create your own live streaming server using just xmoov.php (yes, the php script by itself).

You can also install ffmpeg (linux) like I'm doing to convert the video that is being saved by your HD Canon 5D mk2 camera or a more basic webcam, whatever you choose because this is your server!


Now, let's get started:

1.) Go to: http://stream.xmoov....load/xmoov-php/

No worries, this link is completely valid and mcafee siteadvisor can proove it.

2.) Click "xmoov-php" and on the next page, scroll down slightly and click on accept to down load a zip file

3.) Extract that zipped files or open in your Archive Manager (linux)

4.) (LINUX) In the archive manager, double-click the zip folder and single-click/select ONLY the xmoov.php file and extract it.

4.1) (WINDOWS) Extract the xmoov.php file.

5.) Go to your website's http document root and copy the xmoov.php file there

6.) (LINUX) if you want to at this time, open your terminal, log in as root (su root/sudo root), and install ffmpeg.

7.) That should be it for right now. Reset your mind. :)

8.) open your xmoov.php file

I'm assuming that your xmoov.php file and video file will be in the same folder, that's why the next two steps below are the same


9.) Look for "XMOOV_PATH_ROOT" and set the second parameter to '', i.e. nothing should be in between the apostrophes.

10.) Look for "XMOOV_PATH_FILES" and set the second parameter to '', i.e. nothing should be in between the apostrophes. You can change this later on if you move xmoov.php to another folder. Just put the folder name with a "/" after its name that will contain your xmoov.php and video files.

11.) Look for "XMOOV_BW_PACKET_SIZE" and set the second parameter to '65'. This is best for me because ffmpeg converts at 600kbits/s, or 75 bytes a second, only sightly higher than that xmoov bandwidth limit so that we don't reach the end of file before we want to.

12.) Look for "XMOOV_BW_PACKET_INTERVAL" and set the second parameter to '1'.

13.) Look for "XMOOV_GET_FILE" and set the second parameter to 'YOUR VIDEO FILE NAME'. I.E. "myvid.flv" Remember, the video file is in the same folder as your xmoov.php file.

14.) Look for "XMOOV_GET_POSITION" and set the second parameter to 'start'.


15.) Scroll down to the first "if" statement that has "isset($_GET[XMOOV_GET_FILE]) && isset($_GET[XMOOV_GET_POSITION])" as its parameter and change it to "true".

16.) scroll down a couple lines to "$fileName" that is being assigned to "htmlspecialchars($_GET[XMOOV_GET_FILE]);" and change that to "myvid.flv" INCLUDE the quotations.

17.) Move down two lines to "$file" that is being assigned to "XMOOV_PATH_ROOT . XMOOV_PATH_FILES . $fileName;" and assign it to "$fileName" DO NOT include quotations. REMEMBER, $fileName has a capital "N".

18.) scroll down to the headers, in particular, "header("Content-Length: " . $fileSize);", delete that. You're not going to need that , remember, this is a live stream, you aren't supposed to know how long the file will be...

19.) Go to file bottom. Inside the while and if statement look for "# clean up" or "$time_difference = $time_stop - $time_start;". Right below "$time_difference = $time_stop - $time_start;" or right above "# clean up" insert "set_time_limit(0);"

20.) Save the file and you're ready to go!

21.) If using ffmpeg, open your terminal, log in as root, and type in "ffmpeg -i INPUT-FILE-LOCATION -s hd480 OUTPUT-FILE-LOCATION/myvid.flv


If xmoov.php is in /var/www/html, output file should be /var/www/html/myvid.flv

start converting your vid live with ffmpeg and watch the live video on your website!

Now you're probably thinking that I am only using already converted files, but you can list files in xmoov.php that are being converted on the spot by ffmpeg. I only gave names because your live streaming files need to have a name while being converted/streamed.

I have it on my server at: http://www.valevarka...om/LiveFeed.php

even though it is not live at this time, but it works! I can do what ever I want, change the cameras at any time, audio, bitrate, microphones, whenever. Even though the up-time is up to me, I don't have to worry about whether or not I will be able to post on demand.

ANY questions, leave them here...

Attached image(s)

  • Attached Image


Is This A Good Question/Topic? 0
  • +

Replies To: Create your own live stream server without RED5

#2 creativecoding  Icon User is offline

  • Hash != Encryption
  • member icon


Reputation: 926
  • View blog
  • Posts: 3,205
  • Joined: 19-January 10

Re: Create your own live stream server without RED5

Posted 09 July 2011 - 02:13 PM

Gotta post this in the tutorials section.

This place is for help.
Was This Post Helpful? 0
  • +
  • -

#3 macb6497  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 80
  • Joined: 25-December 09

Re: Create your own live stream server without RED5

Posted 09 July 2011 - 02:15 PM

View Postcreativecoding, on 09 July 2011 - 05:13 PM, said:

Gotta post this in the tutorials section.

This place is for help.



Missed it...
Was This Post Helpful? 0
  • +
  • -

#4 vibhasyn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-September 11

Re: Create your own live stream server without RED5

Posted 26 September 2011 - 02:44 AM

Please provide a html or php code to use/integrate given xmoov.php file
Was This Post Helpful? 0
  • +
  • -

#5 vibhasyn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-September 11

Re: Create your own live stream server without RED5

Posted 26 September 2011 - 03:01 AM

I am getting these errors, Deprecated: Function set_magic_quotes_runtime() is deprecated in C:\wamp\www\project\video\xoom\xmoov.php on line 178

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\project\video\xoom\xmoov.php:178) in C:\wamp\www\project\video\xoom\xmoov.php on line 196


also, Some garbage data is printed on browser page
Was This Post Helpful? 0
  • +
  • -

#6 macb6497  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 80
  • Joined: 25-December 09

Re: Create your own live stream server without RED5

Posted 26 September 2011 - 07:50 AM

View Postvibhasyn, on 26 September 2011 - 06:01 AM, said:

I am getting these errors, Deprecated: Function set_magic_quotes_runtime() is deprecated in C:\wamp\www\project\video\xoom\xmoov.php on line 178

Warning: Cannot modify header information - headers already sent by (output started at C:\wamp\www\project\video\xoom\xmoov.php:178) in C:\wamp\www\project\video\xoom\xmoov.php on line 196


also, Some garbage data is printed on browser page



Make sure you have an rtmp link to your xmoov.php file in the coding of the video player for your site.

I use JWPlayer.

I'll try to attach my xmoov.php file to give you a working comparison. If you don't see it, it was because it was denied for uploading.

I advise that you replace your xmoov.php file with mine, and then change the file locations (look for "a1.flv") with your file name.

REMEMBER, place the xmoov.php file and your video in the same folder.

Modify the Web player code to include the xmoov.php file as your streamer: 'streamer': 'http://www.mysite.com/livefolder/xmoov.php',



<?php
	/*
	
		xmoov-php 1.0
		Development version 0.9.3 beta
		
		by: Eric Lorenzo Benjamin jr. webmaster (AT) xmoov (DOT) com
		originally inspired by Stefan Richter at flashcomguru.com
		bandwidth limiting by Terry streamingflvcom (AT) dedicatedmanagers (DOT) com
		
		This work is licensed under the Creative Commons Attribution-NonCommercial-ShareAlike 3.0 License.
		For more information, visit http://creativecommons.org/licenses/by-nc-sa/3.0/
		For the full license, visit http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode 
		or send a letter to Creative Commons, 543 Howard Street, 5th Floor, San Francisco, California, 94105, USA.
		
		
	*/


	


	
	//	SCRIPT CONFIGURATION
	
	//------------------------------------------------------------------------------------------
	//	MEDIA PATH
	//
	//	you can configure these settings to point to video files outside the public html folder.
	//------------------------------------------------------------------------------------------
	
	// points to server root
	define('XMOOV_PATH_ROOT', '');
	
	// points to the folder containing the video files.
	define('XMOOV_PATH_FILES', '');
	
	
	
	//------------------------------------------------------------------------------------------
	//	SCRIPT behavior
	//------------------------------------------------------------------------------------------
	
	//set to TRUE to use bandwidth limiting.
	define('XMOOV_CONF_LIMIT_BANDWIDTH', TRUE);
	
	//set to FALSE to prohibit caching of video files.
	define('XMOOV_CONF_ALLOW_FILE_CACHE', FALSE);
	
	
	
	//------------------------------------------------------------------------------------------
	//	BANDWIDTH SETTINGS
	//
	//	these settings are only needed when using bandwidth limiting.
	//	
	//	bandwidth is limited my sending a limited amount of video data(XMOOV_BW_PACKET_SIZE),
	//	in specified time intervals(XMOOV_BW_PACKET_INTERVAL). 
	//	avoid time intervals over 1.5 seconds for best results.
	//	
	//	you can also control bandwidth limiting via http command using your video player.
	//	the function getBandwidthLimit($part) holds three preconfigured presets(low, mid, high),
	//	which can be changed to meet your needs
	//------------------------------------------------------------------------------------------	
	
	//set how many kilobytes will be sent per time interval
	define('XMOOV_BW_PACKET_SIZE', 65);
	
	//set the time interval in which data packets will be sent in seconds.
	define('XMOOV_BW_PACKET_INTERVAL', 1);
	
	//set to TRUE to control bandwidth externally via http.
	define('XMOOV_CONF_ALLOW_DYNAMIC_BANDWIDTH', TRUE);
	
	
	
	//------------------------------------------------------------------------------------------
	//	DYNAMIC BANDWIDTH CONTROL
	//------------------------------------------------------------------------------------------
	
	function getBandwidthLimit($part)
	{
		switch($part)
		{
			case 'interval' :
				switch($_GET[XMOOV_GET_BANDWIDTH])
				{
					case 'low' :
						return 1;
					break;
					case 'mid' :
						return 0.5;
					break;
					case 'high' :
						return 0.3;
					break;
					default :
						return XMOOV_BW_PACKET_INTERVAL;
					break;
				}
			break;
			case 'size' :
				switch($_GET[XMOOV_GET_BANDWIDTH])
				{
					case 'low' :
						return 10;
					break;
					case 'mid' :
						return 40;
					break;
					case 'high' :
						return 90;
					break;
					default :
						return XMOOV_BW_PACKET_SIZE;
					break;
				}
			break;
		}
	}
	
	
	
	//------------------------------------------------------------------------------------------
	//	INCOMING GET VARIABLES CONFIGURATION
	//	
	//	use these settings to configure how video files, seek position and bandwidth settings are accessed by your player
	//------------------------------------------------------------------------------------------
	
	define('XMOOV_GET_FILE', 'a1.flv');
	define('XMOOV_GET_POSITION', 'start');
	define('XMOOV_GET_AUTHENTICATION', 'key');
	define('XMOOV_GET_BANDWIDTH', 'bw');
	
	
	
	//	END SCRIPT CONFIGURATION - do not change anything beyond this point if you do not know what you are doing
	
	
	
	//------------------------------------------------------------------------------------------
	//	PROCESS FILE REQUEST
	//------------------------------------------------------------------------------------------
	
	if(true)
	{
		//	PROCESS VARIABLES
		
		# get seek position
		$seekPos = intval($_GET[XMOOV_GET_POSITION]);
		# get file name
		$fileName = "a1.flv";
		# assemble file path
		$file = $fileName;
		
		# assemble packet interval
		$packet_interval = (XMOOV_CONF_ALLOW_DYNAMIC_BANDWIDTH && isset($_GET[XMOOV_GET_BANDWIDTH])) ? getBandwidthLimit('interval') : XMOOV_BW_PACKET_INTERVAL;
		# assemble packet size
		$packet_size = ((XMOOV_CONF_ALLOW_DYNAMIC_BANDWIDTH && isset($_GET[XMOOV_GET_BANDWIDTH])) ? getBandwidthLimit('size') : XMOOV_BW_PACKET_SIZE) * 1042;
		
		# security improved by by TRUI www.trui.net
		if (!file_exists($file))
		{
			print('<b>ERROR:</b> xmoov-php could not find (' . $fileName . ') please check your settings.'); 
			exit();
		}
		if(file_exists($file) && strrchr($fileName, '.') == '.flv' && strlen($fileName) > 2 && !eregi(basename($_SERVER['PHP_SELF']), $fileName) && ereg('^[^./][^/]*$', $fileName))
		{
			# stay clean
			@ob_end_clean();
			@set_time_limit(0);
			
			# keep binary data safe
			set_magic_quotes_runtime(0);
		
			$fh = fopen($file, 'rb') or die ('<b>ERROR:</b> xmoov-php could not open (' . $fileName . ')');
				
			$fileSize = filesize($file) - (($seekPos > 0) ? $seekPos  + 1 : 0);
			
			//	SEND HEADERS
			if(!XMOOV_CONF_ALLOW_FILE_CACHE)
			{
				# prohibit caching (different methods for different clients)
				session_cache_limiter("nocache");
				header("Expires: Thu, 19 Nov 1981 08:52:00 GMT");
				header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
				header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0");
				header("Pragma: no-cache");
			}
			
			# content headers
			header("Content-Type: video/x-flv");
			header("Content-Disposition: attachment; filename=\"" . $fileName . "\"");
			
			
			# FLV file format header
			if($seekPos != 0) 
			{
                print('FLV');
                print(pack('C', 1));
                print(pack('C', 1));
                print(pack('N', 9));
                print(pack('N', 9));
        	}
			
			# seek to requested file position
			fseek($fh, $seekPos);
			
			# output file
			while(!feof($fh)) 
			{
				# use bandwidth limiting - by Terry
				if(XMOOV_CONF_LIMIT_BANDWIDTH)
				{
					# get start time
					list($usec, $sec) = explode(' ', microtime());
					$time_start = ((float)$usec + (float)$sec);
					# output packet
					print(fread($fh, $packet_size));
					# get end time
					list($usec, $sec) = explode(' ', microtime());
					$time_stop = ((float)$usec + (float)$sec);
					# wait if output is slower than $packet_interval
					$time_difference = $time_stop - $time_start;
					set_time_limit(0);
					# clean up
					@flush();
					@ob_flush();
					
					if($time_difference < (float)$packet_interval)
					{
						usleep((float)$packet_interval * 1000000 - (float)$time_difference * 1000000);
					}
				}
				else
				{
					# output file without bandwidth limiting
					print(fread($fh, filesize($file))); 
				}
			}
			
		}
		
	}
?>

Attached File(s)

  • Attached File  xmoov.php (7.16K)
    Number of downloads: 146

Was This Post Helpful? 0
  • +
  • -

#7 vibhasyn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-September 11

Re: Create your own live stream server without RED5

Posted 26 September 2011 - 10:46 PM

I've installed wowza server.
I've this code:
in my testvideo file:

<div id='container'>The player will be placed here</div>

<script type="text/javascript">
  var flashvars = {
    file:'scrubber.fla',  
    streamer:'rtmp://localhost/project/video/xoom/xoomv.php'
  };

  swfobject.embedSWF('player.swf','container','480','270','9.0.115','false', flashvars,

   {allowfullscreen:'true',allowscriptaccess:'always'},
   {id:'jwplayer',name:'jwplayer'}

  );
</script>




It gives me error like:
server not found: rtmp://localhost/project/video/xoom/xoomv.php

Please suggest solution,
Am I missing something?

Will you please provide the script code where this streamer code is integrated
Was This Post Helpful? 0
  • +
  • -

#8 macb6497  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 80
  • Joined: 25-December 09

Re: Create your own live stream server without RED5

Posted 27 September 2011 - 07:00 AM

View Postvibhasyn, on 27 September 2011 - 01:46 AM, said:

It gives me error like:
server not found: rtmp://localhost/project/video/xoom/xoomv.php

Please suggest solution,
Am I missing something?

Will you please provide the script code where this streamer code is integrated


Yes. The main problem is that xmoov.php is not a RTMP server in itself, so you have to use http://localhost instead of rtmp://localhost. You are looking for a file, not a server.

Did you use my xmoov.php file and then change the video locations? I just want to make sure we're on the same page.


To simplify things: All you need is your livefeed page and the xmoov.php file.


Here's my live feed code:


1.) What's in the HEAD TAG of the webpage:

<script type="text/javascript"

src="SWF Flash/jwplayer/jwplayer.js">

</script>



2.) What's in the BODY TAG of the same webpage:

<div id="container2">Please install an up-to-date Flash Plugin</div>

<script type = 'text/javascript'>

jwplayer('container2').setup({

'flashplayer': 'SWF Flash/jwplayer/player.swf',

'file': 'http://www.valevarkasystems.com/Livefeedorigi/a1.flv',

'backcolor': '000000',

'frontcolor': '6666FF',

'lightcolor': '9999FF',

'image': 'http://www.valevarkasystems.com:40/Pictures/streaming.jpg',

'streamer': 'http://www.valevarkasystems.com/Livefeedorigi/xmoov.php',

'controlbar': 'bottom',

'width': '854',

'height': '480'

});

</script>



See how the file and the streamer are in the same folder?

3.) Use my xmoov.php file and replace the "a1.flv" file names with your file names.

This post has been edited by macb6497: 27 September 2011 - 07:02 AM

Was This Post Helpful? 0
  • +
  • -

#9 vibhasyn  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 26-September 11

Re: Create your own live stream server without RED5

Posted 28 September 2011 - 03:12 AM

Hi macb6497,
Thanx for your reply.

As u said You are looking for a file, not a server.
Yes it is playing flv file now.
What should be code for live webcam streaming?
What should be these fields values: file,streamer?
Does this script support live webcam streaming?
Was This Post Helpful? 0
  • +
  • -

#10 macb6497  Icon User is offline

  • D.I.C Head

Reputation: -6
  • View blog
  • Posts: 80
  • Joined: 25-December 09

Re: Create your own live stream server without RED5

Posted 28 September 2011 - 07:14 AM

View Postvibhasyn, on 28 September 2011 - 06:12 AM, said:

Hi macb6497,
Thanx for your reply.

As u said You are looking for a file, not a server.
Yes it is playing flv file now.
What should be code for live webcam streaming?
What should be these fields values: file,streamer?
Does this script support live webcam streaming?



Here's the thing: I ALWAYS keep the "file" and "streamer" locations the same no matter what; streamer points to xmoov.php and file points to a1.flv, which should be the name of your file.

In my case a1.flv is the name of the file that is being saved in real-time (live) to my computer during a live stream via my webcam (ONLY if the webcam saves in MP4 or FLV format) or via ffmpeg (if the webcam doesn't save in MP4 or FLV). When the stream is over, I take the a1.flv file, change it's name, and place it in a different folder called the "LiveFeed" folder for later viewing by people who have missed the live stream.

The folder containing the xmoov.php file will only ever hold the xmoov.php file and the a1.flv file. The a1.flv file only exists in that folder when I'm doing live feeds and is moved when the feed is done so that I will always be able to use a1.flv as my video player file location.

The script will support direct loading from a webcam file if the file is MP4 or FLV. You can try with other formats if you want. Because my camera doesn't save in MP4 or FLV format, the file created by the camera is named "a2.ogg" and I use FFMPEG to convert "a2.ogg" to "a1.flv" in real-time.


The fact of the matter is that your live feed is working now & you should be able to stream from a real-time file. Just remember to change the download rate in you xmoov.php file to be slightly less than the bitrate of your camera.

This post has been edited by macb6497: 28 September 2011 - 07:22 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1