Step 3: Get the FlashVideo Module

The FlashVideo Module

Ok, so now you've got a server with FFMPEG, you just installed the latest revision of Drupal 5, and now you can barely keep in the excitment! Well, just be patient young grasshopper, we are almost there. To get Flash Video into your website, you will now need to get the conveniently named FlashVideo Module from the Drupal website. Once you have this module, and have installed it in the Drupal core, you are ready to begin.

In order to be truely efficient with this module, it is important to learn how to use it. Well, simply put the FlashVideo module is an easy to use module that expands the Upload module by allowing users to upload videos and attach those videos to any content. Even more exciting, is that FlashVideo automatically performs the very common Flash format conversion as well as create an image thumbnail of any newly uploaded video for every cron cycle (I'll get to this later). Once the video is in Flash format, the video can then be embedded in that node using the very simple [video] tag.

To enable this module for a certain node type, you must first go to the FlashVideo Settings in the Administrator panel, and select the FlashVideo settings for any available node type in the Drupal system. Once the FlashVideo module has been enabled for that node type, you will then notice the modified Upload form when you add new content for that node type.

Once a video has been uploaded, it will then have to wait for the next Cron cycle for the conversion to Flash format to begin. You can manually run the cron operation by going to Administer->Logs->Status Report and then click on the link that says run cron manually. After the video has been converted, it will then be available to any node referencing that video. That node can then reference the video by using the [video] tag, and also reference the video thumbnail by providing the [thumbnail] tag.

Parameters for these tags are provided by using a ":" to indicate a new parameter is being provided. The following format should be used for both the [video] and [thumbnail] tags. [video: param=value ] where param is the name of the parameter being passed, and value is the value of the parameter.

The following parameters can be used...

  • index (For both video and thumbnail tags) - This is used to reference a video when muliple videos have been provided for each node. If no node parameter is specified, then this will reference the node in which the tag resides. Example: [video: index=0] would reference the first video uploaded to that node, while [video: index=1] would reference the second video uploaded to that node.
  • node (For both video and thumbnail tags) - This is used to reference a video in another node. Example: [video: node=10: index=0] would reference the first video uploaded to node 10.
  • fids (For both video and thumbnail tags) - File ID's: This parameter can specify a single File ID, or many File ID's separated by a "-". If many File ID's are specified then those videos will play in that order. Example: [video: fids=6] would play the video for file ID 6, while [video: fids:5-3-34] would play files 5 followed by 3 followed by 34.
  • id (For video tags only) - The id tags are used to play YouTube, Google, and Brightcove videos. For YouTube video's simply just place the ID after the tag. For Google and Brightcove Videos, you will need to place google- and brightcove- respectively at the beginning of the tag. Example: [video:id=google-3754293779500828561] will play video 3754293779500828561 from video.google.com, and [video:id=SmVAWKfJ4Go] will play a video from YouTube with the ID SmVAWKfJ4Go.
  • width (For video tags only) - This parameter will override the default width of the video with the value given from this parameter.
  • height (For video tags only) - This parameter will overide the default height of the video with the value given from this paramter.
  • autostart (Values are true or false, and only used for video tags) - This parameter indicates if the video should start automatically.

The following are examples of using the [video] and [thumbnail] tag system...

  • [video] - The first video uploaded to this node, with all parameters using their defaults.
  • [video: index=2 : width=320 : height=240] - The third video uploaded to this node with dimensions of 320x240
  • [thumbnail: index=1] - The thumbnail for the 2nd video uploaded to this node.
  • [video: autostart=false] - The first video uploaded to this node will not start automatically.


Ok, now that you have learned about this module, let's move on in this tutorial.



this post is very useful to

this post is very useful to me. i want to learn it. good
thanks.

__________________________________________________
software reviews

Great mod

This is really nice mod and you don't even have to pay, what do you want more... UN AMARO LUGANO

LOL

www.tastyfood.tv

Thanks for the module. I was

Thanks for the module. I was wondering if you could implement a function so that you can display the video clip's duration next to the thumbnail. Eg. [thumbnail duration].

i18n and flashvideo modules guide

I download, installed and configure flashvideo without problems.
I just upload and MPG file, run cron manually and the FLV is done without problems :)

http://www.gk3onlineinteractions.net/?q=en/node/1

My problem is the content in other languages like FR or ES:
http://www.gk3onlineinteractions.net/?q=fr/node/2
http://www.gk3onlineinteractions.net/?q=es/node/3

The tag [video] doest works fine for the other two translated content, do i have to delete and upload again the video in each new content translation?

Thanks in advanced.

You shouldn't have to do

You shouldn't have to do that. I will look into this.

Thanks,

Travis.

same problem

i have the same problem. it works but only if I delete the uploads and re-upload for each translation. I also tried

[video: fid=xxx] where the xxx refers to the node id of the original post, but no joy.

Any thoughts?

problems with flv

Nice piece of art.

I got ffmpeg installed.
The module is activated.
Output directory is blank --> files.
Player.swf is in the files directory.

After i upload the video i go and run manually the cron, after that no flv convertion is done. For example:
http://drupal.sukialogic.com/?q=en/node/16

Please some help or guide.
I can give you my admin account if you have some time to take a look.

How the cron knows that some files need to be converted to flv???

Thanks in advanced.

If you look at your code it

If you look at your code it looks like you are using the flashvideo_playlist.php file. Is this file in your root? And if so, then what is up with it not providing you the fid?

http://drupal.sukialogic.com/flashvideo_playlist.php?nid=16&fids=

Also, there might be another problem... according to the code, it looks like that URL and the other parameters that are supposed to go to the flash player might be colliding. I will look into this.

But there is also another problem that I noticed... when I type in http://drupal.sukialogic.com/flashvideo_playlist.php?nid=all&fids=all in the address bar, this should return all your video files, but instead gives me nothing. You might look into this.

Thanks,

Travis.

debuggin

Travis, the file flashvideo_playlist.php exist in the document root.

I added the print "yep i exist"
http://drupal.sukialogic.com/flashvideo_playlist.php

Can i give you my admin user if you have time to look into?

"q=en/admin/logs/status/run-cron"
By the way, how the manually cron knows how many files needs to convert?

I post this on the drupal forum:
http://drupal.org/node/139555

Thanks in advanced.

$echo Kudos

I just wanted to $echo what arcane said, Great Module and Great tutorial. I used your tutorial as a spring board to successfully setup my server to convert video to flash on the fly, and then with your module, allow uploads to my website. I was able to get ffmpeg, lame, and ruby/ffmpeg-php to all play nice together on my Ubuntu server and the module pulled it all together and gave me the functionality I was looking for. I have to admit, I spent two days configuring the server, but once that was all in place the module just worked.

One thing I should bring to your attention though. The first test video I sent up was audio sampled at 1600hz and ffmpeg couldn't do anything with it. I received an error in my apache log that looked like this:

[mp3@hex_address]flv doesn't support that sample rate, choose from (44100, 22050, 11025)
could not write header for output file #0 (incorrect codec parameters)

I added the 22050 sample rate ( -ar 22050) to the ffmpeg command box in the module and it converted fine.

Finally, due to the fact I had been running several tests (i.e. several uploads, cron jobs to convert) I had some failed conversions in the ffmpeg database table. The problem was that even though the conversion had failed, the .flv file was still created in my output directory. Due to this the flashvideo.module would not overwrite it once the conversion began working fine because as far as it new there was already one in the output directory with the same name (I used the same test video, same name).

Instead, I had Windows media player embedded playing the original WMV (failsafe?). This tipped me off that everything was working, I just couldn't understand why the module was playing the Windows media file. Then I checked the database and noticed that the last entry in the ffmpeg table was for a conversion failure before I had changed the sampling rate. I knew then that the file was not being converted with the new option in place. I checked the code in the flashvideo.module and noticed that you check for an output file of the same name in the output directory before allowing a conversion. If one exists with the same name, then the conversion does not happen.

Once I cleared the ffmped db table, removed the failed file from output dir, and ran the conversion again, everything worked as it should. So, the db tables need to be cleared and the file(s) removed from the output directory if you have had some failures before a good test can be run. Well, at least the file needs to be removed from the output directory, or you could just rename your test file, but I like a clean database and output directory without a bunch of failed attempts cluttering things up. But that is just me. :)

Thanks again for sharing your module, great looking code and nice functionality.

Hey, this stuff bores my wife too. :)

jacoder

jacoder, You're post brought

jacoder,

You're post brought me much delight! I am glad that you got it working (even with just a couple of anomolies). I have been very busy lately, but I do plan on making this module much more rugged in the future by adding all the failsafes that you mentioned. Yes, the whole reverting to Windows Media Player is a fail safe... I figured that if the conversions fail a certain number of times (configured by the administrator), then the worst case scenario should be that the video shows up the old fashion way instead of not showing at all.

Also, thanks for the compliments on my coding. I can tell that you also are a software writer, so you probably understand how happy it made me that you actually looked at my code and complimented me on it. You have no idea how much it pleases me to hear success stories.... although there is plenty of room for improvement.

P.S. In my next release, I think that I will add the the audio bitrate conversion as a default. Too many people have had issues because of that.

Great Module

I wanted to say wonderful module, makes things really easy.

One step which I dont think was mentioned in the install was that you should download the flash video player at http://www.jeroenwijering.com/?item=Flash_Video_Player and copy the player file to /files/Player.swf (I had to rename the original file as well) or else video playback will not work.

Again, I'd like to say great job on this module and tutorial as well. Btw, on my debian server getting ffmpeg to install was as easy as

apt-get install ffmpeg

This worked great on my debian server but on ubuntu I got some errors from drupal even though the install seemed to work fine from ubuntu.

Thanks for the compliment!

Thanks for the compliment! I am glad you like the module! My only problem with actually getting to test my module was the fact that I don't have my own server. I have to use a host. Although this is fine and dandy, because I just payed $2.50 / month, and I have everything I already need....

Thanks again for the compliments, and enjoy the FlashVideo module.