Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: PHP/Ming Generated Flash Movies for SL

Lucid Vindaloo
VR Tech
Join date: 25 Jun 2004
Posts: 18
01-02-2006 16:51
I've recently been running some tests in PHP generating Flash movies using the Ming extension. So far I've only put together some preliminary examples but it should be enough to get anyone else started who might be interested in working on something similar. Right now the program only displays a single line of text and serves only as an example that its a working system.

Here are link you would run from your SL Media Texture setting instead of a movie file:
Just add your own string after ?text=
http://www.vrtechnologies.org/php/swftext.php?text= Hello World ;)

And to have a look at the php code used to generate the movie:
[url=]http://www.vrtechnologies.org/php/swftext.txt[/url]

I plan to add more useful functions to this as soon as I have a chance to and would enjoy hearing anyone elses input as to how this may be put to use.
:rolleyes:
_____________________
Lucid Vindaloo
"The same thing we do everynight Pinky..." :P
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
01-03-2006 06:43
/15/3d/80494/1.html
_____________________
i've got nothing. ;)
Lucid Vindaloo
VR Tech
Join date: 25 Jun 2004
Posts: 18
URL Code
01-03-2006 11:58
Apparently the URL I posted got truncated at the end,.. I just wanted to repost and make sure it came through okay this time,...

To load the PHP as a In-World movie use the following link inside your lands media texture setting. Enter your own text after the ?text=

http://www.vrtechnologies.org/php/swftext.php?text=Enter your text here
_____________________
Lucid Vindaloo
"The same thing we do everynight Pinky..." :P
Buxton Malaprop
Mad Physicist
Join date: 8 Jun 2005
Posts: 118
01-03-2006 17:17
I have had a little bit of a play about with this - couldn't get it to work in-world; need to figure out the font situation as I was getting a "font not found" error hosting it on my site, and your one was randomly not working in-world (and no longer actually displaying the message passed).

While having a fiddle about I noticed that QT will apparently cope with just being asked to display a static JPEG image from a URL source.

If you don't want to try to do animation or sound or that sort of clever Flash-needing stuff, it's probably easier to script-create a static image in PHP (with the GD library calls or similar - http://php.net/manual/en/ref.image.php for reference), rather than the apparently precarious (and harder) process of generating Flash.

Combining this with the "per-user video url" trick previously mentioned (see /54/91/71821/1.html for that) could let us get up to all kinds of nonsense - and only needing 1 prim for a video surface! :D (plus external webhost and PHP skillz)

I'll thrash out a "hello <avatar name>" example of this just as soon as I can.

(edit: of course, I apologize in advance if this has all been tried and ruled out before for some reason I have yet to notice.)
Alondria LeFay
Registered User
Join date: 2 May 2003
Posts: 725
01-03-2006 18:15
I played with dynamic text via flash although I did a slightly slower method of shooting an email to a perl script which changes a text file that is dynamically loaded by the Flash script. I think I'll have to see if there is a perl module to create flash anims now. :) (now if QT only supported a bit more modern flash, we could have the flash actionscript actually rpc to an inworld object....)
Buxton Malaprop
Mad Physicist
Join date: 8 Jun 2005
Posts: 118
01-03-2006 19:43
OK, here's what I've found out so far, further to my idea above:

The basic idea works. I have an object on my land next to my video screen, if you click it then the video screen loads a static image with a background and "Hello <Your Name> :o)" on it. I've only tested it for me and one other person - that other person sees my other tests just fine (QT vid-from-www, regular images from-www, and Flash) but gets a black block for the dynamic one.

If you're also investigating this avenue (i.e. generating images with GD - rather than Flash with Ming) and you KEEP on crashing the SL client, then it probably means your PHP script is not sending a Content-Length: header. Web browsers can cope, but QuickTime collapses in a heap without one.

The Workaround:
CODE

ob_start(); // start a new output buffer
ImageJPEG($image,'',75);
$ImageData = ob_get_contents();
$ImageDataLength = ob_get_length();
ob_end_clean(); // stop this output buffer

header("Content-type: image/jpeg") ;
header("Content-Length: ".$ImageDataLength);
echo $ImageData;


That code was lifted from the PHP.net documentation for the ImageJPEG function - see the comments in their online manual pages. This outputs your image with handle $image such that it won't crash the QT stuff.

If anyone wants to try my test stuff out (it'd be handy to know if there's a pattern for who can/can't see the dynamically-generated image), it's usable in-world. TP to my place ("MegaBux", it's in Find), take the blue "UP" Teleport once, then walk to the room at the back. Click on the green box under the video screen for the Dynamic Image test, or the other boxes for the other tests. Please IM me in-world to let me know if it works for you or not.

(all those test boxes use the previously-linked "send this video command to only one client" trick, so they only control what YOU are seeing)
Lucid Vindaloo
VR Tech
Join date: 25 Jun 2004
Posts: 18
FDB Font Pack for Ming
01-03-2006 19:58
Thank you Buxton for pointing out the font issue. Flash actual uses a special font format *.fdb, so you have to have that format of font available on your site. I've included an attachment that has several fdb fonts in it. I used the serif.fdb font on mine. I originally googled these myself, I know there is more out there and there is tools for converting any ttf font to fdb. The downside is acquiring the fonts initially, but the upside that its stored on the server so you can use any fancy or unusual font you want to and be fairly sure other users will still see it correctly.

As far as the randomly not working problem,.. I was having that happen as well. Not at first though, this morning I wasn't really having any trouble, but perhaps if other people are trying to access the same file at the same time. I can try to test that out,..

Good point about QT doing jpeg too. I really want to get animations and sounds going to,.. but in the case of static images GD would work just great. So for this simple text board example GD would make a great replacement. :)
_____________________
Lucid Vindaloo
"The same thing we do everynight Pinky..." :P
Lucid Vindaloo
VR Tech
Join date: 25 Jun 2004
Posts: 18
Update to SWFText Code
01-03-2006 20:12
I made some changes so the program no longer only displays one line of text via the 'text' variable. The program now can have up to 5 lines using the t1 through t5 variables.
i.e. - http://www.vr5.org/php/swftext.php?t1=Hello World&t2=Two&t3=Three&t4=Four&t5=Five

These variable can be used in any combination,..

?t1=Hello&t2=World
Will Print only to line 1 and 2

?t3=Hello&t4=World&t1=:)
And this will print to line 3,4 and then a smiley face to line 1


I've attached a copy of the new php file in text format.
Myspoonistoobig Laxness
Registered User
Join date: 3 Nov 2005
Posts: 15
01-03-2006 21:40
well, that's not really SL specific or, no offense, really anything special. It's sort of a 'hello world', even, as far as PHP and ming goes
....but I wasn't aware you could load flash movies into SL, so thanks for that :D
Lucid Vindaloo
VR Tech
Join date: 25 Jun 2004
Posts: 18
01-04-2006 11:49
From: Myspoonistoobig Laxness
well, that's not really SL specific or, no offense, really anything special. It's sort of a 'hello world', even, as far as PHP and ming goes
....but I wasn't aware you could load flash movies into SL, so thanks for that :D


That was sort of the point,... and why the example program says "Hello World" in fact.
So I suppose I hit my mark. :)

Just for your information, SL movies can be any file format QT can play, including Flash 4 non-interactive movies.
_____________________
Lucid Vindaloo
"The same thing we do everynight Pinky..." :P
Jiggly Puff
Registered Alt
Join date: 7 Jun 2005
Posts: 10
01-07-2006 17:53
I used PHP and Flash to dynamically generate an animations based on data on my website.

I've successfully streamed them in-world.

I used FreeMovie because my webhost did not have the Ming extensions installed.

http://freemovie.sourceforge.net/
Lucid Vindaloo
VR Tech
Join date: 25 Jun 2004
Posts: 18
01-09-2006 18:13
From: Jiggly Puff
I used PHP and Flash to dynamically generate an animations based on data on my website.

I've successfully streamed them in-world.

I used FreeMovie because my webhost did not have the Ming extensions installed.

http://freemovie.sourceforge.net/


Thx Jiggly Puff :) Looks like another good piece of software to look into. And a good alternative for those who don't have access to Ming on their server. :) This link is definetly a keeper. :)
_____________________
Lucid Vindaloo
"The same thing we do everynight Pinky..." :P
Jiggly Puff
Registered Alt
Join date: 7 Jun 2005
Posts: 10
01-09-2006 20:14
Not a problem. Unfortunately the generated flash files seem to get rather large after a while... but I haven't been developing anymore, so I didn't quite get the hang of the entire set. I probably could have saved some memory here and there :-D