[Embed Video] A simple module to embed youtube, google, or remote .flv videos
apippin
Joined: 2007-06-11
Posts: 190 |
Posted: Tue, 2007-06-12 14:06 | |||
Ok, so this is my first post, and it comes with a module! I've been using Gallery and Gallery2 for many years, and decided it was time to make my own, small, contribution back to the project. I was faced with a need to share Home Video Clips with family and friends all over the world. I don't have the internet bandwidth to stream these videos directly from my server at home where my Gallery2 installation resides. My only option was to host my Home Videos on sites outside my home, and embed them as items in my gallery album pages directly. Other posts suggested ways of doing this that involved pasting the embedded video player code directly in the description field of a photo item in gallery. This was tedious, and I was seeking a faster, more automated way, of adding video content in a similar fashion. This module attempts to automate that exact process. The new module is called "Embed Video" (embedvideo) which extends ItemAddPlugin. It takes, as input, a URL in the "AddItems" interface of Gallery to a youtube, googlevideo, or remote .flv file, and adds an embedded video object in a gallery item to that URL. It uses the youtube API to extract the title, description, and thumbnail for a youtube video URL. It also parses the raw HTML of the video page for google videos (since no google video API exists yet) to get this same information for those URLs. There are no additional external PHP library dependencies or .ini changes required, and no direct patches needed to the underlying Gallery2 framework for this module to function properly (with 1 patch exception mentioned below). Because this module is still using the "embed videos via html in the description field of a gallery photo item" process, there is a patch that must be made to the GalleryUtilities.class if you want to edit the item after it has been added to your gallery. If you don't want to edit the item after it has been added to your gallery, no patch is required. The process of editing the item will remove the embedded markup in the description field if this patch is not made, and your site is not configured to allow for rawHTML in the description field. The http://gallery.menalto.com/node/54986 post mentions the patch which consists of commenting out line 859 in GalleryUtilities.class. To install it, download the zip file and unzip it to the modules directory. There is an Admin Option page for this module that allows you to configure various options, including adding your own youtube Developer ID if you are embedding youtube URLs. I'm interested in any feedback anyone has to offer on the module (and any bugs for that matter). The module itself is simple and flexible. There are still some things I am not fully happy with and hope to address in future releases (I'm sure there are others you will think of, but here is my short list): 1) no thumbnails for remote .flv file URLs that are embedded I have a codex page created for this module located here: http://codex.gallery2.org/index.php/Gallery2:Modules:embedvideo I also have a simple album demonstrating the different types of embedded videos this module supports adding: For my installation, I had Gallery 2.2.1 installed. This was a single-site installation and I have no idea if it works for multi-site or even if there is any reason why it wouldn't! Enjoy...
|
||||
Posts: 32509
Excellent, thanks!
I thought about such a module a while ago too.
The one thing I'd like to see changed is that you no longer use a hack. Don't abuse the description field to embed the player.
The right way to do this is to create a new GalleryDataItem and a new renderer.
e.g. take a look at modules/flashvideo/, it registers a renderer.
And you need to register a new item type, let's call it GalleryEmbeddedItem (similar to GalleryPhotoItem. I guess it should extend GalleryDataItem.
--------------
Documentation: Support / Troubleshooting | Installation, Upgrade, Configuration and Usage
Posts: 190
I really appreciate your feedback! I've never been comfortable with the hack of "abusing" the description field either. I wasn't sure what else to do, and decided to put my first attempt out there with that hack in place until I received further direction from the local experts in the forum on the matter. On my codex wiki page, I recognize this hack as a drawback/weakness to the module. I too would love to see it go away. I will take your advice, and see how far I can run with it. Thanks!
Posts: 72
Great module! But i have one attention. Why videos must show at top, after file title? Is it possible to place it where pictures show?
---
http://tuning4u.info - tuning photos, movies, wallpapers on desktop
http://tapetyy4u.info - free wallpapers on desktop
Posts: 190
The videos are showing at the top instead of where the picture normally shows due to the overloading of the description field to embed the video. This issue should be resolved once I complete the changes to make a GalleryEmbeddedItem object, and move away from using the description field to embed the video in a GalleryPhotoItem object like I do today.
Posts: 41
Great module!!!
But still have a few questions:
1. How and where do I get the Youtube Developer ID?
2. Using site-admin I've changed video settings: width=450 height=400 as default, but it's still displaying 320 X240. Have I done something wrong?
Posts: 1
i got an error when i try to put the url in the embed.
the error is thisone
Error (ERROR_UNSUPPORTED_FILE_TYPE) : Unable to embed video from: http://youtube.com/watch?v=5DJi0OoEaCc
* in modules/embedvideo/ItemAddEmbedVideo.inc at line 321 (gallerycoreapi::error)
* in modules/core/ItemAdd.inc at line 84 (itemaddembedvideo::handlerequest)
* in main.php at line 231 (itemaddcontroller::handlerequest)
* in main.php at line 94
* in main.php at line 83
Posts: 190
You can get a YouTube Developer ID by logging into your YouTube account, and click on the Developer Profile link. Your developerID will be shown at the top of this form. As for your 2nd question, it doesn't sound like you are doing anything wrong! I've just tested setting my width and height variables to 450 and 400, and the embedded code in the description of the item clearly shows the width and height being set to these values, and the video playback/player also plays it properly at this resolution. I tested this with a youtube video, google video, and a remote .flv file using the internal gallery flash player. So, I'm not able to reproduce the issue on my end. If you check the description field for the item that was added, what width and height are being specified in the embedded code? When changing the variables, are you changing them under the "Defaults" section, or the "Overrides" section of the Site Admin page? I wonder if I have a bug in the "Overrides" section. I just realized I never tested adding variables to that section. <oops> All of my testing has been done by setting the variables in the "Defaults" section of this admin page. Let me know what you find. I think I have a bug there I need to fix if this is indeed the case!
Posts: 190
You are getting the error because of a coding bug on my end. I'm expecting the youtube URL to be "www.youtube.com". If you add a www. to the front of your URL, you should be in business. This is definitely a bug on my end, I shouldn't be this restrictive of the youtube URL, and will fix that.
Posts: 190
I have fixed the issues both of you discovered. I've incremented the module version to 1.0.1, and have uploaded it here. You can download it using the link off the codex page. This new version supports youtube URLs without the leading www, and properly allows the override parameters to trump the default parameters.
Posts: 41
I've tested it under "Defaults" and "Overrides" section. As you can see I've changed settings to 450 * 400 px, but it's not stored. The old values 320 * 250 are unchanged.
Here's my dumpscreen: http://img520.imageshack.us/img520/2919/embedvideolu4.png
Posts: 190
Thanks for the screenshot. Based on what I see, I don't see anything you are doing wrong here! I've setup my module in my gallery to be indentical, and it is working on my end. Have you edited one of these embedded video items that you've added and checked what values it has used in the embedded code in the description field? If you have, you should set the debugOutput=true parameter. There is one piece of debug information that you'll want to uncomment in the code. Edit the ItemAddEmbedVideo.inc file, and uncomment line 61, and send me the output you see after adding a video again.
Posts: 41
Hi,
Problem solved after emptying cache memory.
It's working perfectly. Great module!!
Thanks alot!
Posts: 41
@ apipippin:
Using your easy to handle embedvideo-module, can you modify it so I can upload my movies directly from my desktop / PC?
At this moment you have to submit an url; it doesn't have the opportunity to upload directly from desktop.
Posts: 190
The main thing the embedvideo module brings to the table is the ability to embed videos stored on a remote server, into your gallery pages. This module does not download any part of these remote files into Gallery. It simply embeds links to them. This requires the items it embeds to be web locations, not some arbitrary path to a file stored on your desktop/PC. Fortunately, Gallery2 allows you to upload movie items directly to your Gallery pages. So, if you use the existing features in Gallery2, you should be able to upload a movie from your desktop/PC directly to your Gallery without using the embedvideo module.
Posts: 190
I'm happy to hear that things are working now for you. I also ran into the browser cache issue too when I tried to download the new version of the module. Since I uploaded it to this site using the same name, my browser wouldn't download the new version either when I clicked on the link! It thought "Hey, I already downloaded this file, and it's in my cache, so here you go". It's probably good to note that a browser cache clear is a good thing to do to ensure you download the new version. The other thing I could do is name the uploads differently, where the name of the file contains the version like this: embedvideo_1_0_1.zip I'm not sure what the standard file management process is here for these forums. Any comments on how we should upload our modules, and manage the newer revs of our modules when we release them?
Posts: 41
Hi there,
Yes, to avoid confusions and for smooth handling (cache-memory) it's better to give new versions another names.
Referring to another issue. My server / host doesn't support FFMPEG, so I or other users have to do it manually (setting width, height, creating thumbnails, etc.). Now I'm looking forward that someone is developing a module for easy uploading mpeg, wmv, etc files and automatically creating thumbnails.
Maybe, this might me another solution to resolve the above mentioned problems:
A module that uploads your movies from your PC/ desktop to a remote server (Youtube, Yahoo, Google, etc.), that automatically embeds and displays the corresponding i.e. Youtube-link in your gallery. This might be an extra feature of your module. Can you realize this?
Using a remote-server also diminishes your allocated websitetraffic.
Posts: 190
I understand your point about having a program, tool, or module upload a video to YouTube or other video site and then add a link to it to Gallery automatically. Unfortunately, a lot of these video sites (like YouTube or GoogleVideo) do not implement an upload API. You are forced to use their websites, and their interfaces to upload video content. This makes it impossible to make a tool that can upload vidoes to these sites, and then link them automatically into your Gallery. Because of these issues, a feature like this clearly lies outside the scope of this module.
Posts: 41
Just found out that embedding video's from i.e. Metacafe, Video.yahoo.com, etc. gives trouble.
Please, try to embedd this video from Metacafe: http://www.metacafe.com/watch/470273/aston_martin_db9_volante_in_london/
Embedding videos from Youtube gives no trouble. How to fix this?
Posts: 190
Since each remote video serving site embeds videos a little differently, explicit support must be added to the embedvideo script to handle each one. This module does not possess the web parsing AI to auto-extract the right embedded video information from any arbitrary video site. In my wiki codex page, I explicitly list the video sites that are currently supported. Metacafe and video.yahoo.com are not currently in that list. This would explain why it is giving you trouble. If you would like to make a formal request to have these video sites supported, I can certainly work on adding support for these sites. Just post the video server sites you would like support added for, and a sample video URL that you are desiring to embed from these server sites. That should give me enough information to figure out the best way to add support for these types of sites. If the sites provide an API (like youtube) that is the most robust way to interface with them. However, if they don't offer any APIs, the embedvideo module will have to be enhanced to parse the information from the video pages directly (like it currently does for google video).
Posts: 41
That would be great!
This is a small list of video-sites that need to be supported: video.yahoo.com and metacafe.com
Thanks alot!
Posts: 190
I've looked into both of these video sites. They don't offer any direct APIs for getting information for a single video based on its videoid. So, I won't code up an interface that would add them using their API. However, I can easily parse the information from the webpage extracted from the URL provided for videos on these sites. This is the same approach I use for video.google.com, and is easy to do.
I'm also thinking of changing my width/height code. Instead of forcing a certain aspect ratio, I will see if I can set my width/height directly from the value the video site is using. If I can find this information on the video sites, I will set the width/height to the same value they are using, otherwise, I will set them to the value of the specified width/height parameters in the module. I'll also add a NEW parameter to enable this "autosetting" feature of the width/height parameters. If you have other thoughts, let me know...
Posts: 2
Just installed the module. But I'm getting an error trying to include a video on Google.
Error (ERROR_BAD_PATH) : Unable to get video information at url: http://video.google.com/videoplay?docid=6888554854809881448&hl=en
* in modules/embedvideo/ItemAddEmbedVideo.inc at line 184 (gallerycoreapi::error)
* in modules/core/ItemAdd.inc at line 84 (itemaddembedvideo::handlerequest)
* in main.php at line 231 (itemaddcontroller::handlerequest)
* in main.php at line 94
* in main.php at line 83
The path is OK... Any ideas??
Posts: 190
I'm not sure what happened when you tried to add this video. I've taken the same URL, and added it to my development gallery, and it worked just fine. I haven't been able to reproduce this error with this URL on my end. At this point in the module, it simply makes a call to GalleryCoreApi::fetchWebPage($url, $extraHeaders). For some reason, this call is failing on your end. This same call is made when adding YouTube videos. Have you tried to add one of those to see if it works or not? I've added some extra debug to that error message that might help us understand what HTTP error you are getting. Go ahead and edit line 184, and change it to this:
"Unable to get video information at url: $url - $response"),NULL,NULL);
If that isn't enough information, you can change it to this:
"Unable to get video information at url: $url - $response - $contents"),NULL,NULL);
Let me know what you find...
Posts: 2
I don't get anymore info... $response and $contents are empty
[img]http://www.brutelola.be/d/2143-1/error.jpg[/img]
It works with YouTube videos, I'll dump 'em all on YouTube for now...
Posts: 41
Hi,
Sounds great!
Looking forward to see it working.
Posts: 190
I'm sorry to see this happen. I have no idea why the call to the GalleryCoreApi is not returning any data for a google video URL, yet the same call is working with a youtube URL. When I put in a bad URL, you can see the HTTP response and data in the error message. You are getting no response and no data, which makes me think the GallerCoreApi call is failing in a bad manner, yet it won't tell us why. I don't know enough about the GalleryCoreApi call to know what is going wrong here. You can try chopping off the "&hl=en" from the end of the URL, I don't think it is needed. Other than that, I'm out of ideas. If you can find another call that accomplishes the same thing that works, that would be the trick. Feel free to swap in other calls there if you can find them (or if anyone can suggest one). If you find something that works, I can work it in as a module option to use the alternate call where needed. I understand your current (possibly permanent?) workaround of using youtube over google.
Posts: 1
hi, i've got the same error with brutelola, i just would know if you find the way to correct it.
my error :
Error (ERROR_CONFIGURATION_REQUIRED) : Invalid/missing YouTube developer ID:
in modules/embedvideo/ItemAddEmbedVideo.inc at line 114 (gallerycoreapi::error)
in modules/core/ItemAdd.inc at line 84 (itemaddembedvideo::handlerequest)
in main.php at line 231 (itemaddcontroller::handlerequest)
in main.php at line 94
in main.php at line 83
i'm really interrested about this module.
Posts: 190
I don't think you have the same error that brutelola ran into. I think you ran into the same problem that RSR ran into above. You can get a YouTube Developer ID by logging into your YouTube account, and click on the Developer Profile link. Your developerID will be shown at the top of this form. Once you get this developerID, you need to go to the site admin page, click on the Embed Video link under the Import section, and add the youtubeDevId variable with this value. This should fix the problem you are having, and allow you to enjoy the module. I'm glad you like it, and I hope I can make it even better moving forward.
Posts: 6
Maybe I missed it in the thread, but embed video seems to be ignoring the album thumbnail size? My thumbnails for videos are much smaller than all other gallery thumbnails.
*OKAY* While typing this, I see that it is just youtube videos that make small thumbnails. Any way to fix this?
Also, when I insert a google video using embed video, I notice that it doesnt grab any title information, etc. That is fine, but I would like to be able to add a title myself. When I go to 'edit photo', I add the title and see the video info under description, but when I save it, it breaks the video and I see code on the album page.
Posts: 6
I still didnt find a fix for the thumbnail sizes, but I can live with that....
HOWEVER, I did fix my problem of editing the titles and information. I dont know why it wont fetch the info for google videos, but at least I can edit it now and add the title and info.
To fix it, I followed suggestions here: http://gallery.menalto.com/node/54986
I enabled HTML markup (since only 3 of us can add items, I dont forsee a security risk).
Then I followed Krikkit's suggestion in the above thread, and commented out line 859 in galleryutilities.class.
Thanks for this module Pippin.
Posts: 190
I'm glad you discovered the issue for the embedded code being "sanitized" after you perform an "Edit Photo" operation. Without making the hack you mention, you cannot "Edit Photo" and prevent this from happening.
As for the google video title grabbing issue, embedvideo MUST know how to grab and set the title properly. I'm not happy with a bug like that existing. I think I fixed this issue, but haven't released the code yet with the fix. Can you send me the URL to the google video whose title is not being parsed properly? I want to ensure my bug fix works for your case as well so this isn't happening.
As for the youtube thumbnail issue, right now, I simply grab the thumbnail image directly from youtube, and don't perform any "resizing" or "rescaling" on this thumbnail. So, if they have it small, I store it small without doing an operation to resize it. If I understand your request, I think you are saying that you would like it to resize the thumbnails it grabs to make them the right thumbnail size based on how that thumbnail size is specified for the current album. Is this correct? If so, that doesn't sound hard to do, and I can add it to my feature request list. Thanks!
Posts: 190
I've just released a new version of embedvideo, version 1.0.2, and have attached it here.
Here are the release notes for 1.0.2:
- Added remote file "does not exist check".
- Fixed google video title parsing bug.
- Added support for metacafe.com.
- Added support for video.yahoo.com.
- Added new useRemoteSize parameter (use the remote video size instead of the width and height specified in the module parameters)
- Added new autoStart parameters (specify if the embedded video players should autostart the videos or not)
Posts: 41
Hi there,
Just want to install your revised plugin but saw this error "BAD PLUGIN" :
What went wrong? Filename?
Posts: 190
I've blown away my embedvideo directory, and unzipped the same .zip file I uploaded to the forum in its place. Everything works fine. I can't reproduce the error you are seeing! I'd be interested to know if anyone else hits this problem as well. I don't have any insight to offer here. This looks like an internal Gallery error of some kind. I'm open to any insight from anyone else in the forum about this error. I don't see anything obviously wrong that would cause this to happen. If you find something that works, or isolate the problem, please let me know. Try to uninstall, re-install or de-activate, re-activate the module to see if that has any affect. Where exactly were you when you hit this error? (Plugins screen, parameter screen for embedvideo, or Add Items using the plugin)?
Posts: 190
Make sure you don't have any other embedvideo* directories in your gallery2 modules/ subdirectory. Make sure there is only the one from the zip file in there. Move (or remove) any other ones out of the way. If there are no embedvideo* directories in the modules dir, and you unzip the file, everything should work. I wonder if you have another one you were playing with laying around, or if you moved the old one out of the way before unzipping the new one in its place?
Posts: 41
I've removed the old one and uploaded the revised file. The problem is the filename: I've changed it to embedvideo and it's now working fine!
One more question: how do I modify the thumbnailsize. Now it's default-size is 70 x 70; I want to change it to 150 x 150.
Again it's a great module!!!
Thanks for helping us.
Posts: 190
I believe your thumbnail question ties in with the question choachy made in an earlier post. The trouble with the thumbnails is that I am just taking them at whatever size the remote video servers hand them back to me as. I don't rescale or resize the thumbnails. I'll add this to the feature request list on the codex page for the module.
Posts: 41
Yes, same issue.
I hope you can add the extra thumbnailsize-feature as soon as possible: thumbnail settings only to be changed by administrator.
Thanks in advance.
Posts: 190
I've just released a new version of embedvideo, version 1.0.3, and have attached it here.
Here are the release notes for 1.0.3:
- Added thumbnail resize capability for thumbnails used from remote video servers. The module should now resize the thumbnails it grabs from the remote video servers and make them the right size based on how this is specified in the current album.
Posts: 41
Great!!!!
Thanksalot!
Posts: 2
Its a great module but im having problems when linking to Google Video with regards to the size of the video being displayed.
It should come up as 450x400 but always appears as something like 150x100 no matter what the settings say, I've deleted the cache as someone else stated but still no luck.
Any ideas as apart from that its all working fine.
Cheers
Posts: 190
First off, make sure you have the latest version of the module installed as shown in the Admin -> Plugins page. Look in the installed column for the embedvideo module, and make sure it is 1.0.3. Since I now place the version in the name of the download file, you shouldn't hit the same browser cache problem that others have hit in the past. You can also turn on the debugOutput=true parameter, save the resulting webpage after adding a video, and attach it as a file to a new post here. You can edit the photo item that is added to your gallery2, and check what the width and height are being set to in the embeded html code in the description field. Does that match what you think you are seeing? I think the extracted server side width and height for google videos should be 400x326. Can you check these things and get back to me? Have you tried adding videos from other servers. If so, do they exhibit the same problem?
Posts: 41
Don't forget to add the newest version of your module to the list:
http://codex.gallery2.org/Gallery2:Modules
Posts: 190
Thanks. Great catch. I was missing it there, and still had an older version of the module linked on the "User Contributions" page. I've corrected that as well. I've also marked this module to work on Gallery 2.2, 2.1, and 2.0. I don't have the older versions (2.1 or 2.0) installed anymore to test this theory against. If anyone runs into an issue on these older releases of Gallery, please let me know.
Posts: 2
Im using version 1.0.3, have deleted the cache, output below:
thumbnail: http://video.google.com/ThumbnailServer2?app=vss&contentid=37a1ac03aaaba0a4&offsetms=0&itag=w160&lang=en&sigh=HWVR3JwID9wjmNgGrmS4YBpq5dg
title: On_The_Plane.AVI
thumbnail: d:\www\album\g2data\tmp\add2C39.tmp.jpg
mimeType: image/jpeg
fileName: On_The_Plane.AVI
Video Successfully Added to your Gallery Album
Checking to see if a toolkit that can resize images was found.
Found thumbnail size in album preferences: 150
Resizing thumbnail image to 150: d:\www\album\g2data\tmp\add2C39.tmp.jpg -> d:\www\album\g2data\tmp\add2C3A.tmp.jpg
Posts: 190
Can you post the video.google.com URL you are trying to embed? I'd like to try and reproduce this problem on my end. I don't see anything obvious from the debug output you posted here that would explain why your embedded video size isn't coming out right. Let me know what width and height settings you find for these items in the embedded code shown in the description field for this item.
Posts: 1
I am having the Google Video embedded video size problem as well.
Here is the video I am trying to embed.
http://video.google.com/videoplay?docid=-7775743144629755764
and here is the gallery page
http://hooliganmedia.ca/gallery2/main.php?g2_itemId=53
Posts: 190
I appreciate your post. I was waiting for this information to get to the root cause of the issue. I was able to reproduce the issue, and get a fix in for it. I've tested the URL you provided with the new version of the module, and everything is working great now. The Google Video site changed the way their embedded code was parameterized. After updating my template to match theirs, that seemed to do the trick.
Posts: 190
I've just released a new version of embedvideo, version 1.0.4, and have attached it here.
Here are the release notes for 1.0.4:
- Fixed google video size issues. Improved debug output.
Posts: 1
I installed the plugin a couple days ago. Initially I was getting the same errors as noted above when trying to embed videos (Error_Bad_Path...) but was able to fix the problem by uninstalling, deleting the module folder, re-uploading the module and reinstalling.
Now, I'm able to embed the videos (youtube) but visitors are reporting play issues. The embeded video appears, but when clicking on PLAY the video stalls and freezes on the LOADING screen.
http://www.benanderica.net/gallery/main.php?g2_itemId=324
I experienced the problem myslef initially, but now the videos play fine for me. However, I'm now getting reports from visitors to the site that they are experiencing the same problem.
Any ideas?