Difference between revisions of "Generate Flash Videos"

From TMM Wiki
Jump to navigationJump to search
Line 100: Line 100:
 
</script>
 
</script>
 
</pre>
 
</pre>
 
== Using a Custom Flash Player ==
 
You are not limited to use the flash player that is provided with Carma.  To use a custom flash player you need to copy the files into the carma/site_scripts/ directory and set up any sym-links if your files are linked individually.  After that is done you have to adjust the templates to use your player instead of ours.  Most 3rd party players provide documentation in order to configure them.  The only thing you will need for use is the URL to the flash file.  If the flash player is being used on <tt>view_clip.php</tt>, you can simply use the {rebuild_link} template function:
 
 
<pre>
 
{rebuild_link without="style" using="GET" encode=1 start=$smarty.server.HTTP_HOST}
 
</pre>
 
 
To use a Flash player on a page that is not <tt>view_clip.php</tt>, such as <tt>index.php</tt>, your video source must be entered manualy.  Most flash players will want the path url encoded.  For more information about URL encoding, please see the [http://en.wikipedia.org/wiki/Percent-encoding Percent Encoding] article on Wikipedia.
 
 
Some flash players may need the path to end in a ''.flv'' extension so it knows it is a flash file.  If this is the case then add then to the end of the URL to view_clip.php
 
<pre>
 
&ext=file.flv
 
</pre>
 
This will assist in helping the flash player identifying the file as flash.
 

Revision as of 09:29, 9 April 2009

CARMA
Video Content Admin
The Video Content Admin
Adding Content
Video Clips
Out of Order Video Thumbnails
Content Set Locations
Content Set Categories
Video Format
Flash Player
Generate Flash Videos
Using mp4 Videos
Video Content Names

This article applies to CARMA versions 1.2.2.x and higher. It explains how to generate flash video from existing videos in CARMA and display that video to your members.

The first thing to do when setting up CARMA to use flash is to set up the correct path. In the file carma/includes/create_flash.sh, make sure the correct paths to CARMA and PHP are specified. After the paths are correct, change the permissions for create_flash.sh and create_flash.php to 755 using the chmod command.

Next, ensure the necessary files are installed. Go to the Configuration Admin and look under the Image/Video Manipulation section, you should see entries for "MENCODER" and "FLVTOOL2". Both these programs need to be installed and have the correct path specified.

After the paths to both MENCODER and FLVTOOL2 are set, click on the 'video formats' tab to get the additional options for converting video format to Flash. Checking the 'flash' checkbox lets you to specify the scale, the bitrate, the Frames Per Second (FPS) and the BR (audio bitrate -- we recommend leaving BR at 36). The last column has two blue arrows; these arrows start generating Flash movies for every set in this video format -- generating the videos as fast as possible in the background.

To display videos, make sure your site_scripts directory has the flash_player.swf and the swfobject.js files. If you do not see these two files in your site_scripts directory, run the following commands from the site_scripts directory:

ln -s ../flash/swfobject.js ./swfobject.js
ln -s ../flash/player.swf ./flash_player.swf

Note that the original file is player.swf and the new file is flash_player.swf. The templates look for flash_player.swf

Now that there are new files in site_scripts, you need to link them to the specific site where you want to use them. This is like setting up the site in CARMA for the first time. Go to the document root for your members area and run: ln -s /path/to/carma/site_scripts/* ./ This updates your symbolic links for that site, including the new links required by Flash.

Finally, set up the templates to use the flash player. If you are creating a new site, this should already be set up. If you are adding flash to a site that you have already customized, you may need to add the following lines to your view_clip template. These are a series of 'elseif' statements in this template telling CARMA what to display depending on the video type.

{elseif $mime == 'video/x-flv'}
{* Video type flv *}
{literal}
<script type="text/javascript" src="swfobject.js"></script>
<script language="JavaScript" type="text/JavaScript">
function en_flash_thisMovie(en_flash_movieName){
if (window.document[en_flash_movieName]) {
return window.document[en_flash_movieName];
}
if (navigator.appName.indexOf("Microsoft Internet")==-1){
if (document.embeds && document.embeds[en_flash_movieName])
return document.embeds[en_flash_movieName];
}
else {
return document.getElementById(en_flash_movieName);
}
}

function en_flash_resize(en_flash_args) {
var en_flash_arr = en_flash_args.split('_');
document.getElementById('videoholder').style.width = en_flash_arr[0] + 'px';
document.getElementById('videoholder').style.height = en_flash_arr[1]+ 'px';
}

</script>
{/literal}
<div id="videoholder" style="width:100%;height:100%;">
</div>
<script type="text/javascript">
var so = new SWFObject("flash_player.swf?{$time}", "flash", "100%", "100%", "8");
so.addParam("quality", "high");
so.addParam("scale", "noscale");
so.addParam("swLiveConnect", "true");
so.addParam("allowFullScreen", "true");

so.addVariable("en_flash_movie_width", "auto");
so.addVariable("en_flash_movie_height", "auto");
so.addVariable("en_flash_movie_name", "{rebuild_link without="style" using="GET" encode=1 start=$smarty.server.HTTP_HOST}");
//so.addVariable("en_flash_movie_width", "320");
//so.addVariable("en_flash_movie_height", "240");
so.addVariable("en_flash_jump_value", "6");

so.write("videoholder");
</script>