Embedded Video Improvement

johndbritton
johndbritton's picture

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?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Sun, 2005-12-04 20:52

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.

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Mon, 2005-12-05 01:46

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

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Tue, 2005-12-06 04:11

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.

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Wed, 2005-12-07 02:03

ok im sitting down to start coding, and i opened up the SizeLimit module,

module.inc starts off with

class SizeLimitModule extends GalleryModule {

    function SizeLimitModule() {
        global $gallery;

        $this->setId('sizelimit');
        $this->setName($gallery->i18n('Size Limit'));
        $this->setDescription($gallery->i18n('Define picture size limit'));
        $this->setVersion('1.0.0');
        $this->setGroup('display', $gallery->i18n('Display'));
        $this->setCallbacks('registerEventListeners');
        $this->setRequiredCoreApi(array(6, 0));
        $this->setRequiredModuleApi(array(2, 0));
    }

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

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2005-12-07 16:37

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.

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Wed, 2005-12-07 21:55

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

 
takabanana

Joined: 2005-06-22
Posts: 15
Posted: Mon, 2005-12-19 22:18

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.

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Tue, 2005-12-20 02:09

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?

 
valiant

Joined: 2003-01-04
Posts: 32509
Posted: Tue, 2005-12-20 02:38

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.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2005-12-20 04:56

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).

 
drazin

Joined: 2002-11-23
Posts: 144
Posted: Wed, 2005-12-21 16:10

anyone know how to do somethign like this in a stand alone situation?

 
dummptyhummpty

Joined: 2005-01-18
Posts: 3
Posted: Thu, 2006-01-26 18:23

What's the status of this project? Thanks.

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Thu, 2006-01-26 19:14

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.

 
dummptyhummpty

Joined: 2005-01-18
Posts: 3
Posted: Thu, 2006-01-26 19:32

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.

 
doomdead

Joined: 2003-04-06
Posts: 174
Posted: Wed, 2006-02-22 21:54

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.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2006-02-23 05:57

all of these things are possible.. if anyone wants to work on it feel free to ask questions and we can provide guidance.

 
dummptyhummpty

Joined: 2005-01-18
Posts: 3
Posted: Tue, 2006-02-28 06:25

Ill ask. Where do we start? I have little programing experience either.

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Tue, 2006-02-28 07:35

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

<?php
/*
 * $RCSfile: module.inc,v $
 *
 * Gallery - a web based photo album viewer and editor
 * Copyright (C) 2000-2005 Bharat Mediratta
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or (at
 * your option) any later version.
 *
 * This program is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA  02110-1301, USA.
 */

/**
 * @version $Revision$ $Date$
 * @package FlashMovie
 * @author John Britton
 */

/**
 * This module embeds an flv in gallery pages
 *
 * @package FlashMovie
 */
class FlashMovieModule extends GalleryModule {

    function FlashMovieModule() {
        global $gallery;

        $this->setId('flashmovie');
        $this->setName($gallery->i18n('Flash Movie'));
        $this->setDescription($gallery->i18n('Embed a flv in gallery'));
        $this->setVersion('0.0.0');
        $this->setGroup('display', $gallery->i18n('Display'));
        $this->setCallbacks('registerEventListeners');
        $this->setRequiredCoreApi(array(6, 0));
        $this->setRequiredModuleApi(array(2, 0));
    }

    /**
     * @see GalleryModule::registerEventListeners()
     */
    function registerEventListeners() {
        GalleryCoreApi::registerEventListener('GalleryEntity::save',
            new SizelimitModule(), true);   /* true=disableForUnitTest */
    }

    /**
     * @see GalleryModule::isRecommendedDuringInstall
     */
    function isRecommendedDuringInstall() {
        return false;
    }

    /**
     * @see GalleryModule::autoConfigure
     */
    function autoConfigure() {
        /* We don't require any special configuration */
        return array(GalleryStatus::success(), true);
    }

    /**
     * Event handler for GalleryEntity::save event
     * Copy dimension / filesize limits when the album is created
     *
     * @param object GalleryEvent the event
     * @return object GalleryStatus a status code
     */
    function handleEvent($event) {
        if ($event->getEventName() == 'GalleryEntity::save') {
        }
        return array(GalleryStatus::success(), null);
    }
}
?>

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?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-02-28 15:51

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:

  1. Setup a development install from current CVS or nightly snapshot.. CVS is preferred, then it is easy to generate diffs.
  2. Edit modules/core/CoreModuleExtras.inc, look for GalleryAnimationItem.. the 2nd place you find this you'll see a list of mime types just below it.. add the type for flv (what is the mime type, anyway?)
  3. Also add that mime type to modules/core/classes/helpers/GalleryMimeTypeHelper_advanced.class if needed.
  4. Bump the core module version to apply your changes:
    1. modules/core/module.inc, find the setVersion line and increment the last digit by one
    2. modules/core/CoreModuleExtras.inc, look for "README:" and you'll find some instructions on adding a new version.. basically look for "case 'end of upgrade path'" and just above that add case '1.0.30': or whatever is the OLD core version (if you just changed module.inc to 1.0.31 then you want case 1.0.30)
    3. just below your new case statement put code to add your new mime type (the change in MimeTypeHelper_advanced only adds the type in new installs).. you can copy the content from case '1.0.1' and just adjust the extension/mime type.
    4. search for the next "case 'end of upgrade path'" and add the same "case" line here.. don't need any content after it.
  5. Finally, edit modules/core/classes/GalleryAnimationItem.class
    1. function canBeViewedInline, add the new mime type
    2. function render, the html for embedded display

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.

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Tue, 2006-02-28 21:42

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?

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Tue, 2006-02-28 21:46

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

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Tue, 2006-02-28 21:55

I just added the code to CoreModuleExtras.inc that you can see below:

        case '1.0.30':
            /* Support for Flash Video */
            list ($ret, $mimeType) = GalleryCoreApi::convertExtensionToMime('flv');
            if (!$ret && $mimeType == 'application/unknown') {
                $ret = GalleryCoreApi::addMimeType('flv', 'video/x-flv', false);
                if ($ret) {
                    return $ret->wrap(__FILE__, __LINE__);
                }
            }

I just copied and changed it for flv, from another mime type declaration earlier in the file. What exactly is this code doing?

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Tue, 2006-02-28 22:13

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 :)

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Tue, 2006-02-28 22:38

so heres what ive got so far in the GalleryAnimationItem.class file for the display method case 'video/x-flv'

            case 'video/x-flv':
                return sprintf('<script type="text/javascript">
                    // <![CDATA[
                    if (window.ActiveXObject) {
                        document.write(\'<object id="FLVPlayer" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000">\');
                        document.write(\'        %s\');
			document.write(\'<param name="movie" value="FLVPlayer_Progressive.swf" />\');
			document.write(\'<param name="salign" value="lt" />\');
			document.write(\'<param name="quality" value="high" />\');
			document.write(\'<param name="scale" value="noscale" />\');
			document.write(\'<param name="FlashVars" value="&MM_ComponentVersion=1&skinName=skin&streamName=%s&autoPlay=false&autoRewind=true" />\');
			document.write(\'<embed src="FLVPlayer_Progressive.swf" flashvars="&MM_ComponentVersion=1&skinName=skin&streamName=%s&autoPlay=false&autoRewind=true" quality="high" scale="noscale" width="%s" height="%s" name="FLVPlayer" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />\');
			document.write(\'</object>\');
                    } else {
                        document.write(\'<object id="movie"\');
                        document.write(\'        %s\');
                        document.write(\'        type="%s"\');
                        document.write(\'        data="%s"\');
                        document.write(\'        width="%s"\');
                        document.write(\'        height="%s">\');
                        document.write(\'  %s\');
                        document.write(\'</object>\');
                    }
                    //]]>
                    </script>',

                    /* IE Object */
                    !empty($params['class']) ? 'class="' . $params['class'] . '"' : '',
                    $width,
                    $height,
                    $src,
                    $fallback,

                    /* Mozilla Object */
                    !empty($params['class']) ? 'class="' . $params['class'] . '"' : '',
                    $this->getMimeType(),
                    $src,
                    $width,
                    $height,
                    $fallback);

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!

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Wed, 2006-03-01 04:23

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)

 
dave132

Joined: 2005-07-18
Posts: 4
Posted: Mon, 2006-03-13 18:41

Any movement on this. I am very interested in progressive streamed flv support within gallery2

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Wed, 2006-03-15 01:30

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.

 
dave132

Joined: 2005-07-18
Posts: 4
Posted: Sun, 2006-03-19 03:42

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

<?php
/**
* @version $Id: mosflash.php,v 0.0.1 2005/01/06 01:13:30 mmsidon Exp $
* @package Mambo
* @copyright (C) 2000 - 2005 Miro International Pty Ltd
* @license http://www.gnu.org/copyleft/gpl.html GNU/GPL
* Mambo is Free Software
*/

/** ensure this file is being included by a parent file */
defined( '_VALID_MOS' ) or die( 'Direct Access to this location is not allowed.' );

$_MAMBOTS->registerFunction( 'onPrepareContent', 'botxsstreamstudiobot' );
$siteurl ="$mosConfig_live_site/mambots/content";
$movies ="../../shows";
/**
* Display a flash within your content
*
* @param string relative path to your flashfile
* @param int width
* @param int height
*/

function botxsstreamstudiobot( $published, &$row, &$params, $page=0 ) {
	global $mosConfig_absolute_path;

	// define the regular expression for the bot
	$regex = "#{xsstreamstudiobot}(.*?){/xsstreamstudiobot}#s";

  if (!$published) {
		$row->text = preg_replace( $regex, '', $row->text );
		return;
	}


	// perform the replacement
	$row->text = preg_replace_callback( $regex, 'botxsstreamstudiobot_replacer', $row->text );

	return true;
}

function botxsstreamstudiobot_replacer ( &$matches ) {
	global $mosConfig_absolute_path, $mosConfig_live_site;
	$thisParams = explode("|",$matches[1]);

	if (sizeof($thisParams) != 2) return "Not enough parameters! You must have 3 parameters separated by \"|\" : e.g. {xsstreamstudiobot}myfile.flv|flv|12{/xsstreamstudiobot}";

	$filename = $thisParams[0];
	$filetype = $thisParams[1];

    //==============================================================

   if ($filetype==flv) {
 $text ='<div align="center" style="width:100% ">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="320" height="267">
  <param name="movie" value="'.$mosConfig_live_site.'/mambots/content/flvplayer.swf?file='.$mosConfig_live_site.'/shows/'.$filename.'&autoStart=false">
  <param name="quality" value="high">
  <embed src="'.$mosConfig_live_site.'/mambots/content/flvplayer.swf?file='.$mosConfig_live_site.'/shows/'.$filename.'&autoStart=false" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="320" height="267"></embed>
</object>
</div>
';
 }
    //================================================================
	return $text;
}


?>

 
astapelfeld

Joined: 2006-03-22
Posts: 4
Posted: Wed, 2006-03-22 16:15
mindless wrote:
Recommendations:
..............
Steps:
  1. Setup a development install from current CVS or nightly snapshot.. CVS is preferred, then it is easy to generate diffs.
  2. Edit modules/core/CoreModuleExtras.inc, look for GalleryAnimationItem.. the 2nd place you find this you'll see a list of mime types just below it.. add the type for flv (what is the mime type, anyway?)
  3. Also add that mime type to modules/core/classes/helpers/GalleryMimeTypeHelper_advanced.class if needed.
  4. Bump the core module version to apply your changes:
    1. modules/core/module.inc, find the setVersion line and increment the last digit by one
    2. modules/core/CoreModuleExtras.inc, look for "README:" and you'll find some instructions on adding a new version.. basically look for "case 'end of upgrade path'" and just above that add case '1.0.30': or whatever is the OLD core version (if you just changed module.inc to 1.0.31 then you want case 1.0.30)
    3. just below your new case statement put code to add your new mime type (the change in MimeTypeHelper_advanced only adds the type in new installs).. you can copy the content from case '1.0.1' and just adjust the extension/mime type.
    4. search for the next "case 'end of upgrade path'" and add the same "case" line here.. don't need any content after it.
  5. Finally, edit modules/core/classes/GalleryAnimationItem.class
    1. function canBeViewedInline, add the new mime type
    2. function render, the html for embedded display

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.

I used the mime type "video/x-flv", and added this code to the function render:

		case 'video/x-flv':
    return sprintf(
    '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" 
       codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" 
       width="%s" height="%s" id="%s"%s>
       <param name="movie" value="%s" />
  		 <param name="salign" value="lt" />
		   <param name="quality" value="high" />
		   <param name="scale" value="noscale" />
		   <param name="FlashVars" value="&skinName=%s&streamName=%s&autoPlay=true&autoRewind=false"/>
		   <embed src="%s" flashvars="&skinName=%s&streamName=%s&autoPlay=false&autoRewind=false" 
		   	quality="high" scale="noscale" width="%s" height="%s" salign="LT" type="application/x-shockwave-flash" 
		   	pluginspage="http://www.macromedia.com/go/getflashplayer" />
		   <noembed>%s</noembed>
		   </object>',
		   $width, $height,
			!empty($params['id']) ? $params['id'] : 'movie',
			!empty($params['class']) ? ' class="' . $params['class'] . '"' : '',
			$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf')),
			$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin')), $src, 
			$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf')),
			$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin')), $src,	
			$width, $height,
			$fallback);

After updating, it worked ;)

Alberto

 
azn_oohwee

Joined: 2006-03-06
Posts: 24
Posted: Fri, 2006-03-24 03:15
mindless wrote:
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:

  1. Setup a development install from current CVS or nightly snapshot.. CVS is preferred, then it is easy to generate diffs.
  2. Edit modules/core/CoreModuleExtras.inc, look for GalleryAnimationItem.. the 2nd place you find this you'll see a list of mime types just below it.. add the type for flv (what is the mime type, anyway?)
  3. Also add that mime type to modules/core/classes/helpers/GalleryMimeTypeHelper_advanced.class if needed.
  4. Bump the core module version to apply your changes:
    1. modules/core/module.inc, find the setVersion line and increment the last digit by one
    2. modules/core/CoreModuleExtras.inc, look for "README:" and you'll find some instructions on adding a new version.. basically look for "case 'end of upgrade path'" and just above that add case '1.0.30': or whatever is the OLD core version (if you just changed module.inc to 1.0.31 then you want case 1.0.30)
    3. just below your new case statement put code to add your new mime type (the change in MimeTypeHelper_advanced only adds the type in new installs).. you can copy the content from case '1.0.1' and just adjust the extension/mime type.
    4. search for the next "case 'end of upgrade path'" and add the same "case" line here.. don't need any content after it.
  5. Finally, edit modules/core/classes/GalleryAnimationItem.class
    1. function canBeViewedInline, add the new mime type
    2. function render, the html for embedded display

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.

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.

 
SubaruWRC

Joined: 2004-02-16
Posts: 23
Posted: Tue, 2006-04-04 18:18

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

 
Eka_Mei

Joined: 2006-01-03
Posts: 132
Posted: Thu, 2006-04-06 00:30

I'm nto entirely sure how this work after reading the instruction. Have anyone else tried this?

 
Banta

Joined: 2006-04-18
Posts: 35
Posted: Thu, 2006-04-20 20:56

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....

Quote:
Edit modules/core/CoreModuleExtras.inc, look for GalleryAnimationItem.. the 2nd place you find this you'll see a list of mime types just below it.. add the type for flv (what is the mime type, anyway?)
Also add that mime type to modules/core/classes/helpers/GalleryMimeTypeHelper_advanced.class if needed.
Bump the core module version to apply your changes:

modules/core/module.inc, find the setVersion line and increment the last digit by one
modules/core/CoreModuleExtras.inc, look for "README:" and you'll find some instructions on adding a new version.. basically look for "case 'end of upgrade path'" and just above that add case '1.0.30': or whatever is the OLD core version (if you just changed module.inc to 1.0.31 then you want case 1.0.30)
just below your new case statement put code to add your new mime type (the change in MimeTypeHelper_advanced only adds the type in new installs).. you can copy the content from case '1.0.1' and just adjust the extension/mime type.
search for the next "case 'end of upgrade path'" and add the same "case" line here.. don't need any content after it.
Finally, edit modules/core/classes/GalleryAnimationItem.class

function canBeViewedInline, add the new mime type
function render, the html for embedded display
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.

Now, apply the last step of code, also from above....

Quote:
case 'video/x-flv':
return sprintf( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="%s" height="%s" id="%s"%s>

<param name="movie" value="%s" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars" value="&skinName=%s&streamName=%s&autoPlay=true&autoRewind=false"/>
<embed src="%s" flashvars="&skinName=%s&streamName=%s&autoPlay=false&autoRewind=false" quality="high" scale="noscale" width="%s" height="%s" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
<noembed>%s</noembed>
</object>',
$width, $height,
!empty($params['id']) ? $params['id'] : 'movie',
!empty($params['class']) ? ' class="' . $params['class'] . '"' : '',
$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf')),
$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin')), $src,
$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf')),
$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin')), $src,
$width, $height,
$fallback);

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&amp;g2_itemId=26&amp;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!

 
johndbritton
johndbritton's picture

Joined: 2005-03-23
Posts: 78
Posted: Thu, 2006-04-20 22:19

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.

 
Eka_Mei

Joined: 2006-01-03
Posts: 132
Posted: Thu, 2006-04-20 22:53

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.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Thu, 2006-04-20 22:55

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!

 
Banta

Joined: 2006-04-18
Posts: 35
Posted: Fri, 2006-04-21 20:56

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

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Fri, 2006-04-21 22:08

$urlGenerator->generateUrl(array('href' => .....), array('forceFullUrl' => true));

 
Banta

Joined: 2006-04-18
Posts: 35
Posted: Sat, 2006-04-22 00:38

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

 
Banta

Joined: 2006-04-18
Posts: 35
Posted: Sat, 2006-04-22 08:50

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

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2006-04-23 04:12
Quote:
$urlGenerator->generateUrl(array('href' => .....), array('forceFullUrl' => true));

is placed in the top of the render function:

Quote:
function render($format, $params) {
global $gallery;

$fallback = trim(preg_replace("/[\r\n]/", '', $params['fallback']));

switch($format) {
case 'HTML':
$urlGenerator =& $gallery->getUrlGenerator();
$src = $urlGenerator->generateUrl(
array('view' => 'core.DownloadItem', 'itemId' => $this->getId(),
'serialNumber' => $this->getSerialNumber()),
array('forceFullUrl' => true));

also here:

Quote:
$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf'), array('forceFullUrl' => true)),
$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin'), array('forceFullUrl' => true)), $src,
$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf'), array('forceFullUrl' => true)),
$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin'), array('forceFullUrl' => true)), $src,

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.

 
mindless
mindless's picture

Joined: 2004-01-04
Posts: 8601
Posted: Sun, 2006-04-23 15:41

what's the problem? the player is too picky about the url? what is the requirement?

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2006-04-23 16:28

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?

 
Banta

Joined: 2006-04-18
Posts: 35
Posted: Sun, 2006-04-23 20:21

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

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Sun, 2006-04-23 23:15

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

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2006-04-24 01:49

Ok, I know what to do, I just don't know how to go about it.

We need to replace the "&amp;" 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&amp;g2_itemId=501&amp;g2_serialNumber=2 does not.

 
Banta

Joined: 2006-04-18
Posts: 35
Posted: Mon, 2006-04-24 02:22

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 "&amp;" entity. It should be do-able. With that we can forget about the Url Rewrite Mod.
__________
Banta

 
Banta

Joined: 2006-04-18
Posts: 35
Posted: Mon, 2006-04-24 03:01

Just gave it a try with high hopes. Replacing &amp; 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.

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2006-04-24 03:15

Whoahoooo got it working and no rewrite!
here is the code:

Quote:
case 'video/x-flv':
$flvUrl = str_replace('&amp;', '%26', $src);
return sprintf( '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,0,0" width="%s" height="%s" id="%s"%s>

<param name="movie" value="%s" />
<param name="salign" value="lt" />
<param name="quality" value="high" />
<param name="scale" value="noscale" />
<param name="FlashVars" value="skinName=%s&autoPlay=true&autoRewind=false&streamName=%s"/>
<embed src="%s" flashvars="skinName=%s&autoPlay=false&autoRewind=false&streamName=%s" quality="high" scale="noscale" width="%s" height="%s" salign="LT" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />
<noembed>%s</noembed>
</object>',
$width, $height,
!empty($params['id']) ? $params['id'] : 'movie',
!empty($params['class']) ? ' class="' . $params['class'] . '"' : '',
$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf'), array('forceFullUrl' => true)),
$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin'), array('forceFullUrl' => true)), $flvUrl,
$urlGenerator->generateUrl(array('href' => 'modules/core/data/flvplayer.swf'), array('forceFullUrl' => true)),
$urlGenerator->generateUrl(array('href' => 'modules/core/data/skin'), array('forceFullUrl' => true)), $flvUrl,
$width, $height,
$fallback);

Have fun!

-Wayne

 
suprsidr
suprsidr's picture

Joined: 2005-04-17
Posts: 8339
Posted: Mon, 2006-04-24 03:58

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.