G2 and DivX player (How do I get G2 to auto-generate embed code?)
|
evilc
Joined: 2004-08-01
Posts: 47 |
Posted: Wed, 2008-06-18 14:13
|
|
The title says it all really. I want G2 to automatically generate the HTML embed code for divx movies. I can code PHP, so given that I know what to edit I can probably do what I need. There is a code generator here I guess it could recognise a DivX AVI by MIME type or something? Failing that, renaming my files to a .divx extension would be an accebtable solution. |
|

Posts: 47
OK, I worked out that I probably need to edit modules/core/classes/GalleryMovieItem.class
I have been mucking around and this is the code I have so far:
I have had to hard-code preview image for the moment as I do not see the variable name for that.
Unfortunately, at the moment, I have issues with uploading the new GalleryMovieItem.class - I think the file is owned by admin and I have no shell access, so I cannot chown it - is there a function in G2 that will do a chown or a chmod of modules/core/classes/ for you?
Posts: 47
UPDATE
I got somewhere!
At the top of GalleryMovieItems.class is the line
static $mimeList = array(
Add a line below:
'video/x-divx',
I modded the case statement to:
And I also edited the gallery table g2_mimetypemap and added an entry
divx|video/x-divx
I also edited the MIME types on my apache server and added .divx as video/divx
Upload a divx WITH THE EXTENSION .divx (If it is .avi you can rename it to .divx)
Works for me.
Currently no thumbnails working, and I have hard-wired a preview image in my code above, but I am working on it.
Still find it hard to believe that I am the first person out there to embed divx using the divx player in G2... If someone knows of someone else who has it fully working, lemme know. Otherwise, any offers to help develop this to it's full potential please let me know!
Posts: 47
Demo of this is now up at http://g2.evilc.com/index.php?option=com_g2bridge&view=gallery&Itemid=7&g2_itemId=16
Currently uploading as .avi and modding the video/x-msvideo section until I can work out how to get G2 to try and make a thumbnail for a .divx file
Posts: 7884
this would be your thumbnail:
list ($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($this->getId())); if (!$ret && !empty($thumbnail)) { $thumbUrl = $urlGenerator->generateUrl( array('view' => 'core.DownloadItem', 'itemId' => $thumbnail[$this->getId()]->getId(), 'serialNumber' => $thumbnail[$this->getId()]->getSerialNumber()), array('forceFullUrl' => true, 'forceSessionId' => true, 'htmlEntities' => false));so it would be:
although not sure if it need to be urlencoded.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 47
Thanks everso much for that suprsidr, that was spot on.
[i]I am using this code currently:
case 'video/x-msvideo': list ($ret, $thumbnail) = GalleryCoreApi::fetchThumbnailsByItemIds(array($this->getId())); if (!$ret && !empty($thumbnail)) { $thumbUrl = $urlGenerator->generateUrl(array( 'view' => 'core.DownloadItem', 'itemId' => $thumbnail[$this->getId()]->getId(), 'serialNumber' => $thumbnail[$this->getId()]->getSerialNumber()), array('forceFullUrl' => true, 'forceSessionId' => true, 'htmlEntities' => false)); return sprintf( '<object classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616" codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab" width="%s" height="%s"> <param name="custommode" value="none"/> <param name="previewImage" value="%s"/> <param name="autoPlay" value="false"/> <param name="src" value="%s"/> <embed type="video/x-divx" src="%s" custommode="none" width="%s" height="%s" autoPlay="false" previewImage="%s" pluginspage="http://go.divx.com/plugin/download"> </embed> </object>', $width, $height, $thumbUrl, $src, $src, $width, $height, $thumbUrl); } else { return $fallback; }One slight snag though - the thumbnails are a bit small, would like them full res. However that would then make the album pages a bit slow. Is there a way to get it to make a second, full res image to use as the previewImage? (See here)
Posts: 7884
I'm sure it could be hacked in somewhere, but gallery does not produce other derivative images for movie items besides the thumb.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 47
Grr, I have no idea why but as of today it spontaneously stopped working. When I click on the previewImage to play, it just sits there on "Connecting..."
Works fine on my localhost server...
Posts: 47
Well, still no joy getting G2 to generate thumbs for videos with a MIME type of video/x-divx, but I DO now have a workable solution.
1) Delete any divx MIME types you may have in G2 and add the divx extension to video/mp4. You may also want to add the xvid extension too.
2) Edit GalleryMovieItem.class
FIND:
Make a line after and paste in this:
Now MAKE SURE you upload DIVX files as extension .divx
To change the MIME type of an existing video based upon it's file extension, you can use SQL like the following on your gallery database:
(Change the characters ".divx" in that code to say ".avi" to, for example, set the MIME type of all .avi files to video/mp4)
If, in the gallery admin for a file, you change the file extension, it will actually change it on the disk so the above method would then work for it.
IF YOU CHANGE THE MIME TYPE OF AN EXISTING FILE LIKE THIS, AFTERWARDS, GO TO THE GALLERY ADMIN MAINTENACE SECTION AND FLUSH THE DATABASE CACHE ELSE YOU WILL NOT SEE THE CHANGE!
So now anything uploaded with a .divx extension maintains the .divx extension but uses the MP4 section in GalleryMovieItem.class. This means that all MP4 files will play in the divx player, but that shouldn't be a problem, it should be able to handle them as the new player handles MP4/AVC (AKA H.264) as well as MP4/ASP (AKA DIVX/XVID).
If a fix does come along in the future to get G2 to attempt to create a thumbnail for a MIME type of video/x-divx, then you can just run the SQL above (replace the text video/mp4 with video/x-divx) to change all divx files to the proper divx MIME type, so the bodge is future-proofed ;)
Now all I need is a mod for G2Image to allow it to generate the HTML for a DIVX and I will be away! A workaround for that in the meantime is to make your gallery data dir inside the docroot and delete or modify the .htaccess file in the G2 data folder to allow access to the underlying files. Then set your Joomla files folder to the same folder as the gallery data folder so that image pickers etc can pick files from the gallery. JCE's media manager will quite happily embed a divx into an article with the click of a button, unfortunately you will not get the thumbnail that G2 generated using ffmpeg with that, which is why I want to mod G2image to be able to generate the divx embed code. I know how to do that, it's just that the link that G2Image gets is a gallery query not a link to the underlying file, which the divx embed code doesn't seem to like. If anyone knows how to fix it, lemme know, cos that's the ultimate solution...
Happy hacking...
Posts: 9
Hi,
thanks for working out this solution!
I've got a problem with the gallerysid cookies.
The Divx Web player claims about only playing .divx or .avi.
Sourcecode reveals theres the cookie attachment which causes this problem.
When I logout and do it as guest, it works, because there is no ?g2_gallerysid.... attached.
*domain and filename changed.
Is there already a workaround for it?
Posts: 7884
in gallery2/modules/core/classes/GalleryMovieItem.class line ~228 defines the src:
$src = $urlGenerator->generateUrl( array('view' => 'core.DownloadItem', 'itemId' => $this->getId(), 'serialNumber' => $this->getSerialNumber()), array('forceFullUrl' => true, 'forceSessionId' => true));change 'forceSessionId' => true to false.
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 54
Hi, I'm trying to use .divx video on my gallery, and I tried to work on database and on GalleryMovieItem.class, but without any luck.
First of all I edited the gallery table g2_mimetypemap and added an entry
divx|video/x-divx
I used phpMyAdmin and I run this query:
INSERT INTO `hostpoin_G2LCal`.`g2_MimeTypeMap` (`g_extension`, `g_mimeType`, `g_viewable`) VALUES ('divx', 'video/x-divx', '0')After I eited GalleryMovieItem.class and after case 'video/mp4':" I've inserted:
Now If I upload a video with a .divx extension I can only download this video, but I can't see it directly.
I edited the video and set the correct width and height, but if I try to open the movie, I still see "Download movie" .
My only purpose is to see .divx movies with divx palyer, directly from my G2, I'd like also to be able to load a JPEG image to use as the thumbnail for this movie.
Thanks for any suggestion, and sorry for my bad english.
Posts: 7884
OUCH! the MIME Maintenance module which ships with gallery can handle that for you.
in GalleryMovieItem.class you need to add video/x-divx to function canBeViewedInline
and then add your code in function render
-s
FlashYourWeb and Your Gallery with The E2 XML Media Player for Gallery2
Posts: 54
Thanks for your reply, I've modified function canBeViewedInline and function render, but now I see a request for downloading a plugin: looks like mimetype "video/x-divx" is not recognised by the browser.
Looking at my code in render function I see
<embed type="video/x-divx" src="%s"and If I modify in<embed type="video/divx" src="%s"everything worksThanks very much for your help!!!