Embedded Video Improvement
johndbritton
Joined: 2005-03-23
Posts: 78 |
Posted: Sun, 2005-12-04 16:16 |
FFMPEG supports conversion to .flv (flash video) which is from what I read the same format as the video for google video. I am incredibly impressed with the speed and usability of the google video player, and would like to have uploaded videos to my gallery automatically converted to that format and embedded for playback using the google video player, or similar. I have read that the google video player is hard coded to just video hosted on video.google.com http://www.nanocrew.net/?p=114 I also read that FFMPEG supports FLV http://soenkerohde.com/tutorials/ffmpeg/ Finally as an alternative to google video player I think any FLV player would be suitable http://www.martijndevisser.com/2005/10/flv_player_updated.html I have about 2 years of PHP experience and experience with OOP (but not in PHP) I have a feeling that I would be able to develp this module if it is possible. Is anyone here experienced with FLV? I believe the site http://www.current.tv also uses FLV to stream their video I really would like this functionality, as it is cross-platform browser independent (im using firefox in linux and it works flawlessly) Where should I start? |
|
Posts: 32509
transcoding from one video formtat to another is computationally quite expensive. if you are on a shared webhosting account, this won't be an option.
if you've got a dedicated webserver, this shouldn't be a problem.
what is needed for such a module?
- convert movie files on upload to .flv with ffmpeg with a ItemAddOption, see the sizelimit or the quotas module as examples for such an option
- a new entity type, GalleryFlashMovieItem extends GalleryDataItem or maybe better extends GalleryMovieItem
- in your render method , you'll output the right html such that the flash movie player is invoked.
Posts: 78
I do indeed have a dedicated server
of the three steps I have an idea of how to do the third:
- in your render method , you'll output the right html such that the flash movie player is invoked.
but i am unclear as to how I should do steps one and two... It would also be nice to be able to upload files in flv already (for people on shared servers)
at the moment, i need to return to my homework... but i will look at the sizelimit and quota module tomorrow
Posts: 78
I had a problem enabling FFMPEG... I posted about it in the support forum... once I get that resolved I will continue with this, any help would be appreciated.
Posts: 78
ok im sitting down to start coding, and i opened up the SizeLimit module,
module.inc starts off with
what do the setGroup, setCallbacks, setRequiredCoreApi, setRequiredModuleApi functions do?
I figure the setCallbacks function tells gallery when to use the code provided by the module
also what does $gallery->i18n('Display') do?
I am thinking I should create
class FlvEmbedModule extends GalleryModule
In the sizelimit module the function RegisterEventListener is used to call a function whenever GalleryEntity::save is called (no?)
what event listeners should I use for the flvembed module?
I have a lot of questions, as this is my first gallery module. Thanks for the help
-John
Posts: 8601
group is where the module shows up in the installer/upgrader and site admin.
i18n marks a string for translation but doesn't actually perform the translation (some code later will do so).
required apis make sure your module will function in the G2 where it is installed.. if your module uses a new api added in core api 6.9, for example, then the module would refuse to activate in a G2 that only has core api 6.3. When we make an api change that is not backwards compatible (infrequent, but this will be happening before gallery 2.1) we bump the first digit of the api version.. when G2 uses module api 3.0 it won't allow any module requiring any 2.x version to run.. those modules must be reviewed and brought inline with current api changes, and set to require 3.0.
Posts: 78
thanks, ive got a CSII project due at midnight tonight (I hate finals week), ill be working on this module once i finish... back to work
Posts: 15
Keep us updated! I'm also wanting FLV support within Gallery2...
The dude at DropShots (www.dropshots.com) has a Client exe that the user just drags-drops their movie files (MPEG, AVT, QT, etc) onto that converts files to FLA (or maybe it's SWF) on the client's PC, uploads it, and puts it into a calendar on their server. I actually pay for their service (only $5 a month) but would also love to see something similar within Gallery2.
Posts: 78
I'm still planning on doing making this module, finals week just ended so hopefully I'll be able to work on this module over the winter break, from what I read gallery may be having an API change soon so I might wait until the new API is updated to make my module. Does this seem like a good idea to the gallery devs? or will it be easy to port to the new API?
Posts: 32509
all api changes will be documented and for some changes, there will be convert scripts to convert your sourcecode. so you don't really have to wait, the major part of your module, the logic, organization etc will be the same.
Posts: 8601
you can also access BRANCH_API_DEV in CVS and develop against that.. there are likely a few more changes to come, but most of the planned changes are already available (and documented here).
Posts: 144
anyone know how to do somethign like this in a stand alone situation?
Posts: 3
What's the status of this project? Thanks.
Posts: 78
I am still interested in the project, but I have been very busy recently with my new job and the spring semester. As I make progress I will keep this post updated, but I don't see any progress in the immediate future.
Posts: 3
I know how having school and a job can be! Good luck with both. Have you done any work/research that maybe I could look at (or continue)? If you have AIM you can IM me at Audiboy117.
Posts: 174
I'm also interested in having the ability to embed flash videos into gallery, the same way google does. I'm even up for using google as a host and just using the applet within gallery. but i wouldnt mind hosting it myself.
Would be nice to be able to upload a video to google, then add a video (on a seperate host), have a template where you can manually edit the applet/object code, then just provide the url and it will build it and embed it for view.
Posts: 8601
all of these things are possible.. if anyone wants to work on it feel free to ask questions and we can provide guidance.
Posts: 3
Ill ask. Where do we start? I have little programing experience either.
Posts: 78
OK so here is what i say we should do for the first release of this:
allow the upload of a .flv, and render it with an embedded flash player.
To do this I will need to:
"create a new entity type, GalleryFlashMovieItem extends GalleryMovieItem"
And
"in the render method , output the right html such that the flash movie player is invoked."
This is about as simple as this problem can be made, any additional features can be added to the base module later.
My question to the gallery devs is how do I go about creating a GalleryFlashMovieItem
I took the sizelimit module and just edited the module.inc file as follows
Where should I create the new entity type?
Im assuming that i will have to create an eventhandler for the render event, so that I can invoke the flv player, where/how would i do that?
And lastly how do I tell gallery to allow uploads of .flv simply from the install of this module?
Posts: 8601
Recommendations:
1) I suggest developing for G2.1 rather than 2.0.x
2) If you were doing this only for your own use then a module would be a good idea.. but since you're working with the dev team I think you should develop a patch for core module that we can then roll into the product.
This means instead of a new GalleryFlashMovieItem we should modify the existing core code to also support flv.. which do you think makes more sense? GalleryMovieItem which does other movie types, or GalleryAnimationItem which already handles application/x-shockwave-flash mime type? I'm leaning towards the latter.. keep flash stuff together.
Steps:
Now load any page and you'll jump to the upgrader.. after upgrade you should be able to add flv and get a GalleryAnimationItem. Now you can view the item and tweak the render code until it displays right.
Posts: 78
OK, got the CVS version installed, and i've been looking for the correct mime type.
i've come up with it being either video/x-flv or flv-application/octet-stream but im not sure which one to use.
I read somewhere that video/x-flv is not an official IANA mime type so I'm leaning toward adding both mime types unless anyone has a good argument against that.
I also agree that it is best to keep the Flash stuff together and will be writing the support into the GalleryAnimationItem. As far as I can see its just a symantics thing, where i put it shouldn't really make a functional difference, should it?
Posts: 78
I just had a thought that the flv-application/octet-stream may be the flv player that I would embed into the page, but again im unsure.
Also im adding the mime type to the GalleryMimeTypeHelper_advanced.class file, and from what I see, I can only put in one mime type per extension so for now i will be going with the video/x-flv mime type, and see how far I can get
Posts: 78
I just added the code to CoreModuleExtras.inc that you can see below:
I just copied and changed it for flv, from another mime type declaration earlier in the file. What exactly is this code doing?
Posts: 8601
if 'flv' isn't a known extension (only would be if added to this install via Mime module) then add it during core upgrade.
you're right that the choice between MovieItem and AnimationItem is just code organization; it would work in either.
sounds like you're making good progress
Posts: 78
so heres what ive got so far in the GalleryAnimationItem.class file for the display method case 'video/x-flv'
I'm not really sure where to go from here. I could use some explanation on the ActiveXObject and what is "// <![CDATA["? why are we using document.write? And finally where should I put the FLVPlayer_Progressive.swf file? it is basically a flash object that takes an flv and plays it. Changing this file would allow you to modify how the controls look etc.
Off to class till 10PM est, I feel like im actually making some progress now!
Posts: 8601
hm, i think put the swf file in modules/core/data. you'll probably want to use $urlGenerator to make a string to place in the output.. $urlGenerator->generateUrl(array('href' => 'modules/core/data/FLVPlayter_Progressive.swf'));
<![CDATA[ and ]]> are required for javascript blocks to pass xhtml validation.
looks like it uses document.write to have different html based on the browser type. if you can find some html output that works for both IE and other browsers then you won't need this... (see GalleryMovieItem.. it has some complex funky tags that manages to work on all browsers)
Posts: 4
Any movement on this. I am very interested in progressive streamed flv support within gallery2
Posts: 78
I haven't had any spare time to work on this since I last posted... eventually I'll get it working, feel free to write some code and post it here, I will continue to watch this thread and keep you all updated.
Posts: 4
Maybe this will help. This is a bot I use in a Joomla CMS site that takes 2 parameters filename and filetype (flv) and embeds the flv in the content using a opensource flv player "flvplayer.swf."
here it is working on the site http://www.jasonupton.net/com/index.php?option=com_content&task=view&id=237&Itemid=365
Posts: 4
I used the mime type "video/x-flv", and added this code to the function render:
After updating, it worked ;)
Alberto
Posts: 24
Does this apply to any extension/mime type? For example could I use this method to add "video/mp4" or "video/avi". If so what changes would I need to make to make this happen? This information could be very useful in the WiKi i've been looking for it forever.
Posts: 23
Could this also be applied to ASX streaming media files?
I am looking at code to do the exact same thing, except for ASX files instead at http://gallery.menalto.com/node/37888
Posts: 132
I'm nto entirely sure how this work after reading the instruction. Have anyone else tried this?
Posts: 35
So Close Now!
Ok This ALMOST works. What I need help with is converting the string that defines the path to the .FLV
file into something that the .SWF player will understand. Following the instructions above....
Now, apply the last step of code, also from above....
Cool, all goes well. I did get a file integrity warning upon update, but, it wasn't crucial.
Here's the problem, the flash player ('modules/core/data/flvplayer.swf') doesn't like the funky code that
is beng passed to it. The code is in this line....
<param name="FlashVars" value="&skinName=%s&streamName=%s&autoPlay=true&autoRewind=false"/>
and it renders like this... ( in my case )
<param name="FlashVars" value="&skinName=modules/core/data/skin&streamName=main.php?g2_view=core.DownloadItem&g2_itemId=26&g2_serialNumber=2&autoPlay=true&autoRewind=false"/>
Which fails. HOWEVER, if we put an absolute path in... BINGO EYES! It plays.
<param name="FlashVars" value="&skinName=%s&streamName=http://localhost/gallery2/modules/core/data/MyMovie.flv&autoPlay=true&autoRewind=false"/>
So the question is, how can we make the %s in the streamName= call out a path that the player will understand?
I am working locally using IIS for the server and have my data in a folder that is not web accessible. SWF files are found and played nicely.
I think that if this part can be worked out, then all we will have to do is upload any FLV to an album and it will play like a RonCo Infommercial. Which will be VERY COOL indeed.
Close. Code Guru's,,, let's put this one down!
Posts: 78
Good work, I'm dying to see this work, im really glad you've done as much work as you have to get this far. I'll take a better look at the code and see if I can help you out when I get home from class.
Posts: 132
I agree, this look fantastic. The gallery can finally handle one of the fastest growing media type as popularity of digital video increases greatly over the last few years. Yay! ^^
And I can finally convert the 200 or so video files from the old mpg format to flash media so It will have some good compatiblity.
Posts: 8601
once you guys work out the details, post a patch and a link to a sample file i can try, and i'll review this work.. thanks!
Posts: 35
I'm at a standstill with this.
What is needed to pass the proper URL into the path as outlined above?
Is there a module or something that will do this? I'm pullin my hair out trying to work this last bit out.
As stated above, passing the url( is it called short url ?) correctly to the SWF player will solve this problem.
How is it done? Please help
Thanks
__________
Banta
Posts: 8601
$urlGenerator->generateUrl(array('href' => .....), array('forceFullUrl' => true));
Posts: 35
Thank you for your help. I really appreciate it.
Sorry to be a dufus, but where would I add this code?
I tried adding it to the file 'GalleryAnimationItem.class' , but that just kills the app.
http://gallery.menalto.com/node/42656
I poked into this topic and this seems to be sortof working like I think is going to be needed. If you look at h0bbel example page and right click on the image, you get the correct URL path ( but there is a '?' added). In this example, under "Photo Properties" there is a link "summary Details". Clicking on this link and then checking out the image properties is the correct link without the addition of the '?'.
So, I feel I am close, just need a little more direction on where to put this code. Even if it acts globally and puts the correct url everywhere. That would be fine.
Thank you for your continued patience and help in this matter.
_________
Banta
Posts: 35
OK,
I FINALLY got this working and it seems to be peachy.
I couldn't get the Url Rewrite Mod to work under IIS, not sure why so I went ahead and
installed an Apache server.
The long and short of it is that the Url Rewrite module must be enabled in order for this to work.
I'll post detailed instructions if anyone is interested.
For now, all you have to do is upload the FLV and click on the link, and it plays. That was all I was hoping for.
Thanks for all the guidence. I would still like to know what...
$urlGenerator->generateUrl(array('href' => .....), array('forceFullUrl' => true));
is suppose to do and where it is suppose to be placed. It would be nice to get this working without having to have the URL ReWrite mod enabled, or at least find a way to make it work on IIS
__________
Banta
Posts: 8339
is placed in the top of the render function:
also here:
And it does indeed force the full url, but I fear that you are correct in that the Url Rewrite module must be enabled.
Although I was able to get the full url, the flvplayer still cannot understand it. I even placed ".flv" after the %s in the streamName=%s.flv as a last ditch effort to no avail
As my server is IIS, there is no rewrite for me.
mindless, I'm wondering if there is a way to decode the url for the player's benefit?
Other than the streamName url it works perfectly.
Posts: 8601
what's the problem? the player is too picky about the url? what is the requirement?
Posts: 8339
I think the problem with the url lies with the ampersands in gallery urls.
Flash interprets & as a break in the string for the next element or arguement. eg <param name="FlashVars" value=skin=skinName&autoPlay=true&autoRewind=false....
and with gallery's urls containing so many "&" I think flash is interpreting them as such.
Is there a way to get shorter more normal urls without the rewrite mod?
Posts: 35
suprsidr,
Did you try to put in an absolute url in the flashvars parameters for testing, as below?
<param name="FlashVars" value="&skinName=%s&streamName=http://localhost/gallery2/modules/core/data/MyMovie.flv&autoPlay=true&autoRewind=false"/>
Try this and report if that is working. It should. Just place both of the player .swf files and the test.flv file into the folder modules/core/data/ for now and then load any .flv from an album. Whatever test.flv file you have should then play.
I do know from my experiments that the player does not like the .swf extention on the skin. So,it is possible that it will also not like the .flv. However, I think the .flv will be rendered properly at the end of the string. Meaning, it will work with or without the .flv at the end of the streamName variable.
The "&" ampersands are not an issue with the flashplayer interpretation. In fact, if you load up Dreamweaver (8) and insert an .flv, by going to insert>media>flash video, the code that is placed into the html for the flashvars parameters looks something like....
<param name="FlashVars" value="&skinName=modules/core/data/skin&streamName=modules/core/data/Bonus3&autoPlay=true&autoRewind=true"/>
So, the ampersands are expected but, it is interesting to note that the .flv extention is left off of the streamName variable. I think "?,= and ;" are more likely to be breaking the call into the player.swf
I agree that it would be nice if we can figure out how to render the proper string without the reWrite Mod, with or without the .flv extention. Even if it had to be done with a "Custom Field". Now, I am shooting in the dark, but, why could we not code it like this.
1). For each Flash movie that we load into the gallery, we define a custom field like..
customfield=http:/localhost/the/proper/path/ourmovie.flv
2). Then in the call for our streamName, we could call in something like..
<param name="FlashVars" value="&skinName=%s&streamName=CUSTOMFIELD&autoPlay=true&autoRewind=false"/>
Now that is totally bassackwards and a shot in the dark, but may or may not be a sollution for IIS or, anyone having issues getting UrlRewrite mod functioning. It would take a little extra work defining the path, but, would be a worthwile work around.
Thoughts?
__________
Banta
Posts: 8339
Banta,
I do and have had a working test setup for the gallery flv player http://209.254.158.237/flvtest.html its a rather large movie, so it may take a sec or two to load for you. The gallery version is here: http://209.254.158.237/G2Bridge/index.php?&g2_itemId=20
In my travels with flash programming, I know that the ampersand is used to separate variables, notice that they are used to separate the different variables in your example above skinName, streamName,autoPlay...., so it would go to say that if the stream url had them in it it would just be another separator.
I myself have flashcomm server, so I know I could rig this to work. But that is not the point here. We want this to work for everybody.
I have another flv player here: http://209.254.158.237/trailers/player.html that I made for another site and it plays off an xml playlist - so maybe there is a way on the flash side to make this work. I'll start looking into that now. Maybe we could use rss.
I would be interested in knowing what rules you setup in rewrite for this to work. I'll try it on my linux box
Thanks
-Wayne
Posts: 8339
Ok, I know what to do, I just don't know how to go about it.
We need to replace the "&" in the url for the movie to "%26" see this page for flash special chars: http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_14143
I tried it here http://209.254.158.237/flvtest1.html where streamName=http://209.254.158.237/gallery2/main.php?g2_view=core.DownloadItem%26g2_itemId=501%26g2_serialNumber=2 and it works.
When this streamName=http://209.254.158.237/gallery2/main.php?g2_view=core.DownloadItem&g2_itemId=501&g2_serialNumber=2 does not.
Posts: 35
THAT'S INTERESTING!! It would also solve the issue of having the rewrite mod enabled.
I tested out the URL's that you posted. Man, I love Flash Video! It took all of two whole seconds for the long video to begin to play. That is fantastic.
To answer your question about the reWrite Mod Settings, the only one that seems to matter is the one that you are advised against enabling in the mod parameters.Which is URL REWRITE/DOWNLOAD ITEM. Enable that and leave the default parameters....
d/%itemId%-%serialNumber%/%fileName%
After that, your string should work, even though it is still formatted goofy. When I say goofy, I am referring to the following code in BOLD but, nevertheless, it still works...
<param name="FlashVars" value="&skinName=/GALLERY2/modules/core/data/Clear_Skin_3&streamName=/GALLERY2/main.php/d/21-1/Bonus3.flv&autoPlay=true&autoRewind=true"/>
I know that extra code is needed for something, and as long as it works, I am ok with it. I would like to get rid of main.php though. The .php bothers me but, as long as the question mark isn't there, it seems to be good.
One thing I should mention is that I could not get the mod_rewrite option to take in the Url Rewrite mod. I had to go with the PHP method, which was the only one that would take after I installed the Apache Web Server.
I am going to look into what you have pointed out above about replacing the ampersands with the "&" entity. It should be do-able. With that we can forget about the Url Rewrite Mod.
__________
Banta
Posts: 35
Just gave it a try with high hopes. Replacing & with %26 in the streamName did not work for me. Also, I had a look at the link you provided above and it does not play. I am not sure how you had it working but, it is pretty interesting and got me thinking about other ways to make this work.
Hang in there, we'll get it nailed.
Am I wrong, or does the UrlRewrite mod simply NOT work in IIS under any settings? I sure thought I read that the ISAPI version would work under IIS, but, I can't even get it to take.
Back to the drawing board. The simplest of things are driving me nuts. If we could just get a definitve answer on how, if possible, to pass the correct absolute url in GalleryAnimationItem.class, we could put this to rest.
Posts: 8339
Whoahoooo got it working and no rewrite!
here is the code:
Have fun!
-Wayne
Posts: 8339
Try it in my gallery http://209.254.158.237/G2Bridge/index.php?&g2_itemId=20 I uploaded another movie.(both are over 500Mb)
Also about ISAPI rewrite. I tried it a long time ago, and got it to work after days of trial and error config. Not worth the time or headache.
Remember to switch off rewrite to try my code.