-
YouTube display (with php/youtube proxy) opensource.
Posted on April 25th, 2009 No commentsYou can find this at xstreetsl.com here: https://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=1415280
This tool allows you to show YouTube video in SecondLife or OpenSim.
This was relatively easy to do before April 2009, but when google changed the way mp4 downloading is done (probably to reduce the bandwith overall load on their computers),
older tools stopped working.
This solution works very similarly to previous one but caches the mp4 version temporarily for 6 hours on the php server. This is done to avoid the 3-4 minute delay in asking YouTube converting the video to mp4 and providing a fast link usable by various people for some hours.
Since the hosting space and the bandwitdth of the php server can be rapidly exhausted if all the world will use it I added a simple password that needs to be put on the description of the viewer to enable the tool to work. You can ask me the password if you want to access our community website (http://opensimita.org) or you can upload the two php scripts wherever you want. (You need to create a mp4 folder and set proper access to it).
How to use this tool if you are just using it as *normal* user:
====================================
1\ Rez it. It should give a hint:
Wings.YouTube.May2009: Listening on channel 10 for a youtube url
2\ Change the Object Description with proper password for accessing the website. This password must match that decided by the WebSite owner. You might also need to change the sURL in the internal script if you are not using our community server.
string sURL=”http://opensimita.org/lsl/youtube.php”;
3\ Write in chat
/10 http://www.youtube.com/watch?v=6jPPYrBD0To
writing *exactly* what you put in your browser
a) If you receive something like:
[3:53] Wings.YouTube.May2009: Request to convert video sent, waiting…
[3:53] Wings.YouTube.May2009: Changing mediaparcel to: Invalid password
You need to set the correct password in Object description
b) if everything is ok you should receive the following on public chat:
[3:54] Wings.YouTube.May2009: Request to convert video sent, waiting…
[3:54] Wings.YouTube.May2009: Changing mediaparcel to: http://opensimita.org/lsl/mp4/6jPPYrBD0To.mp4
It it is the first time you decode a youtube movie it can take some 2-3 minutes to decode to mp4, otherwise it should be almost immediate.
4\ if a person touches the screen will receive a load URL to open up an external browser to the same video. This might be very useful if peopel cannot set up properly the client for viewing multimedia content (last resort)
How to setup website if you are an *expert* user
===============================
1\ You must have your php enabled website www.example.com
2\ Open a ftp connection and build a folder “lsl” and a subfolder “lsl/mp4″ give the correct rights to mp4 subfolder so that the webserver can put files there (usually 775 or 777)
3\ copy the youtube.php and the rmtmpmp4.php files under lsl
4\ choose a password and put it into the youtube.php just at the beginning:
<?php
$password=”xxxx”;
5\ communicate this password to people using your website. They must change the :
string sURL=”http://www.example.org/lsl/youtube.php”;
AND the description of the screen object
If you want to change the 6 hours delay prior to deleting cached copies of mp4 you must go
into rmtmpm4.php file and modify the line
$expire_time_hours = 6;
as you prefer
Here are the opensource scripts: main lsl script
// This script is OpenSource protected by CC: by Salahzar Stenvaag, nc, sa // It listen to channel 10 and when chatting a youtube url it will // call an external website obtianing a mp4 version that is then set in media // of current parcel. // // Script is documented also on alisl.org/wings website. // // There are various issues on correctly setting tools like this for multimedia // and group owned parcels. Please have a look for instance to this page // http://wiki.secondlife.com/wiki/User:Salahzar_Stenvaag/classes/StreamingMedia // for better understanding if you have problems. // // This script and php related scripts might not work if google youtube changes // its policies of converting movies in mp4. This has already happened in // April 2009, so it can happen again
// change this to the location where you uploaded the youtube.php and rmtmpmp4.php
// scripts
string sURL="http://opensimita.org/lsl/youtube.php";
// probably you should NOT touch after this point
integer iDEBUG=0; // set this to 1 to have
string sTHEVIDEO;
key kREQ;
DEBUG(string str)
{
if(iDEBUG==1) llSay(0,str);
}
integer iSECRET=1234;
HTTP(string url, list l, integer post)
{
integer i; l+=[ "pass", llGetObjectDesc() ];
integer len=llGetListLength(l);
if(len % 2 == 1) len++;
string body;
for (i=0;i 0 ) body+="&";
body += llEscapeURL(varname) + "=" + llEscapeURL(varvalue);
}
string str;
if(post==1)
{
string hash=llMD5String(body,iSECRET);
str=url+"?hash="+hash+"&"+body;
DEBUG("url called in post: "+str);
kREQ = llHTTPRequest(url+"?hash="+hash,[HTTP_METHOD,"POST",HTTP_MIMETYPE,"application/x-www-form-urlencoded"],body);
}
else
{
str=url+"?"+body;
DEBUG("url called in GET: "+str);
kREQ=llHTTPRequest(url+"?"+body,[],"");
}
}
default
{
on_rez(integer num)
{
llResetScript();
}
state_entry()
{
llListen(10,"",NULL_KEY,"");
llSay(0,"Listening on channel 10 for a youtube url");
}
listen(integer channel, string name, key id, string url)
{
// use the url to call HTTP
HTTP(sURL,[ "url", url ],0); sTHEVIDEO=url;
llSay(0,"Request to convert video sent, waiting...");
}
touch_start(integer num)
{
llLoadURL(llDetectedKey(0),"Go to the video",sTHEVIDEO);
}
http_response(key reqid, integer status, list metadata, string body)
{
if(reqid==kREQ)
{
if(llStringLength(body)==0)
{
llSay(0,"Refreshing request...");
HTTP(sURL,[ "url", sTHEVIDEO ],0);
return;
}
//kREQ=NULL_KEY;
llSay(0,"Changing mediaparcel to: "+body);
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_TYPE, "video/mp4", PARCEL_MEDIA_COMMAND_URL, body, PARCEL_MEDIA_COMMAND_STOP ]);
llParcelMediaCommandList( [ PARCEL_MEDIA_COMMAND_STOP , PARCEL_MEDIA_COMMAND_PLAY ]);
}
}
}
youtube.php script
<? $password="*****"; // this script must be called with ?url= // for instance ?url=http%3a%2f%2fwww.youtube.com%2fwatch%3fv%3ddrXr82qBRyg%26pippo%3d54%0D%0A // note that url MUST be urlencoded to not confuse HTTP parser // to have enough time for getting translated file set_time_limit(0); // get url from ?url= parameter $url=$_GET["url"]; if($_GET["pass"]!=$password) die("Invalid password"); // get original file from Youtube with the token in it $token = file_get_contents($url,NULL); // define what a "word" is for us $WORD="[A-Za-z0-9_=-]*"; // get name of the video from url scanning v= preg_match_all("/v=($WORD)/",$url,$matches); $vid=$matches[1][0]; $fname="mp4/$vid.mp4"; $extname="http://opensimita.org/lsl/".$fname; if(file_exists($fname) ) die($extname); // check if we already have this file // get token value from content scanning "t": "" preg_match_all("/ \"t\"\: \"($WORD)/",$token,$matches); $token=$matches[1][0]; // ask youtube video in mp4 format $mp4file="http://www.youtube.com/get_video?fmt=18&video_id=". $vid . "&t=" . $token; //echo $mp4file." "; $fp=fopen($mp4file,"rb"); $fp1=fopen($fname,"wb"); while(!feof($fp)) { $buf=fread($fp,256000); fwrite($fp1,$buf); } fclose($fp); fclose($fp1); die($extname); ?>rmtmpm4.php : Remove every 6 hours script called by the previous
<? // Define the folder to clean // (keep trailing slashes) $captchaFolder = 'mp4/'; // Filetypes to check (you can also use *.*) $fileTypes = '*.mp4'; // Here you can define after how many // minutes the files should get deleted $expire_time_hours = 6; // Find all files of the given file type foreach (glob($captchaFolder . $fileTypes) as $Filename) { // Read file creation time $FileCreationTime = filectime($Filename); // Calculate file age in seconds $FileAge = time() - $FileCreationTime; // Is the file older than the given time span? if ($FileAge > ($expire_time_hours * 60 * 60)){ // Now do something with the olders files... print "The file $Filename is older than $expire_time_hours hours\n"; // For example deleting files: // echo "removing $Filename "; unlink($Filename); } } ?> -
Generating multitexture slides to save time and money in uploading and holding slide conferences
Posted on April 14th, 2009 2 commentsCurrently there are many systems for teaching and showing slides in SL and/or OS. Apart from the streaming solutions which are a bit difficult to handle in SL (you need to own expensive land and to set complex deeded objects), slide presenters with image caching are already a good solution. As I told many times I don’t like to spend time and L$ to upload a presentation.
A typical presentation from mine is around 20 slide for 1 hour inworld experience. This would cost 200 L$ which is almost 1 US$. It is not so much, but if I can choose I prefer to spend much less. What about using only 5 uploads i.e. 50 L$, this would be around 20 cents, and it is also much more fast to organize when you upload.
Unluckily the preparation of this smart system can be a bit difficult, but when set up the first time you can use it happily for the other yours presentations
Recipe for the presentation:
0\ The best would be using Zan Printer which offer an embedded JPG printer which automatically produces multi textures without any blank space. You need to rotate the multitextures produced by Zan since they are rotated by 90 degrees.
Video for using zan:
Unluckily Zan Printer is NOT free so here I propose an alternative solution which is free, but needs some extra steps and will have some percentage of wasted space.
1\ I normally use word to prepare my presentations this is because it is much more easy to lay out textual information. If you used Power Point you can use native “export to jpg” mechanism which can be easier. The first step is to export the sequential list of your slides. To export jpg’s from Word you can use the free gnostice printer plugin (http://www.freedownloadmanager.org/downloads/Print2eDoc_58341_p/free.htm) this will add a new printer. Remember to choose as output format jpg and the correct folder where you can find out your images.
Video for installing gnostice and producing JPGs:
2\ Now you need to merge 4 pages in one. I use the contact sheet feature from XnView. Specify all the JPG images in the correct order (order by name) and make contact sheet specifying 2048×208 2×2. And yes you have the final JPG.
Video for producing proper contact sheets:
Next post for the tool inworld opensource making use of this.
-
A script for handling a transparent cursor on slides.
Posted on April 11th, 2009 No commentsThis has been already discussed in the past: if you have some slides and want to point to a specific part of the image you now can with the new features offered from September 2008. Some people did offer some scripting solutions but everytime the software was nomodify and closed. The other interesting point is that we are using only *ONE* prim with a convenient transparent texture so that the script is really simple to write and (possibly to understand).
What I’m offering here is a free and *opensource* solution. Simple to use:
1\ rez your ordinary screen
2\ rez a “glass” i.e. a transparent thin object just in front of your screen and put inside this script:
// Creative Commons: by, nc, sa (attribution, noncommercial, share alike) // Created by Salahzar Stenvaag April 2009 SET() { vector touched=llDetectedTouchST(0); llOffsetTexture(1-touched.x+.025, 1-touched.y+.025, ALL_SIDES); } default { state_entry() { llSetTexture("2ca752b1-894c-bc78-6e49-b021238d6dbc",ALL_SIDES); } touch_start(integer total_number) { SET(); } touch(integer total_number) { SET(); } }
3\ I used a “cursor” made of an empty red circle. You can upload your own texture with your cursor in the bottom left corner. Clicking and dragging the mouse will move and drag the cursor all over so you can use this cursor for everything you need.Salahzar
-
Wings Educational group to have more developments in 2009.
Posted on April 11th, 2009 No commentsDuring this spring we will try start many activities with Wings group. The activities will be on the following points:
- Experimenting various educational tools bridging RealLife with SecondLife and OpenSim (sloodle, moodle, other local tools)
- Setting up a repository sim in SL on Solaris (and / or other sims)
- Establishing a regular schedule of trainings for educators using simple SL tools
Everybody willing to help can contact me inworld (Salahzar Stenvaag)..While waiting for the next developments, I’ve found a very interesting **free** tool for printing from Word or any other powerpoint like program on Windows. Previously the only usable method was to use Zan Printer which was a bit costing (60$). Now you can do it free!!!
These are very useful to spare 75% lindens on uploading textures to SecondLife!!!Here the instructions:
1\ Go to http://sourceforge.net/projects/imageprinter/ and download the zip version of that software.
2\ Unzip it and launch the installer. At the end it will ask you for best configuration: choose JPG and choose folder where you want to store the output (default: c:\)
3\ from word or any other wordprocessor or powerpoint, when printing you can choose a new printer “Image Printer”, tell it to print 4 pages per page and to choose the “landscape” orientation. On advanced if needed you can select a high resolution format (600×600).
4\ You now have in c:\ or wherever you choose many .jpg combined multitextures that can be used with my tools.
NB: First lesson I will give in May will be on how to use these multitexture in sl or os.


