Flash Video in Drupal 5: A complete multimedia tutorial.


Introduction:

When I first started getting very familiar with Drupal about 5 months ago, I realized that, while it was an incredible CMS, it still lacked the video capabilites of todays leading Web 2.0 websites. Although I was very impressed with the versatility of the current Video module, I was not impressed with how incredibly non-user friendly the module was... well, from a non-developer point of view. You see, my goal was to create a user-generated video website. You know what I am talking about. You see them freakin' everywhere! YouTube, Google video, AOL video, and I could just go on and on.

The problem with the current Video module is that is was not designed for a User-generated video website. It was only created to allow a web developer the ability to easily upload a video, and display that video. This web develpoer is able to do this by creating a Video node and provide what seems like a thousand different parameters to embed that video in his site. This is where I see the problem... First of all, I don't beleive that a video should be considered a "node". A video is simply a file, and should be treated as such. And Drupal already has a fantastic module that allows a user to easily upload files to any node in the system, the Upload module. What is even more cool about this module is that the user is given the ability to upload as many files to their node as they wish. This got me thinking... This should also apply to video; Why shouldn't I be able to upload as many videos to my node as I wish? If a video is not considered a node, but rather a file, then this would be possible using the Upload module. In fact, it would be stupid easy for anybody creating content. So stupid easy, that in fact, anybody (not just a web developer) can do it. You see where I am going here, don't you. By using this video content philosophy... You would, in fact, have a brand new video module built for the user-generated websites, and as far as I am concerned, the websites that WILL be and ARE the future of the web. I would like to introduce to you, the brand new FlashVideo module which I wrote to do just this... Take a look for yourself! (oh, and I'm not an animal hater... I just thought these videos were heeeelarious!)

I don't think you can do this easily with the current Drupal Video module. But with the brand new FlashVideo module, this is EASY!!!

In this tutorial, I will walk you through step by step on how to create your very own Web 2.0 website with integrated Flash Video. I will teach you how to use this new module that I have written, FlashVideo, and personally show you how easy it SHOULD BE to add Flash video to your Drupal 5 website. So sit back, pop them fingers, and get ready for Web 2.0.

save your trouble

I think if you want to save all your troubles

you can always go to CrayonHost

they already got things in place an have great support

look at my website for sample site

Anton Soeharyo

path problem

Hi Travis

thanks a lot for all your time.
I have a clearly defined problem but no clue how to solve it.

exactly did all you explained
when I upload the movie there is a problem with the path:
++++++++++
warning: rename(/var/www/drupal-5.0//var/www/drupal-5.0/files/wwwBI_T29_T31.avi,/var/www/drupal-5.0//var/www/drupal-5.0/files/94_wwwBI_T29_T31.avi) [function.rename]: No such file or directory in /var/www/drupal-5.0/modules/flashvideo/flashvideo.module on line 1464.
++++++++++
as you see the "/var/www/drupal-5.0/" is for some reasons doubled :-(
this of course messes up the whole thing of conversion etc etc

I would appreciate any help...
thanks
selim

As always is happens...

As always is happens... after my last post, 5 min. later, I got the solution.

changing the
"File system path" solves the problem
cheers

install issue

Travis - again, great module.
One issue in the install file, though, is that mysql (v. 5.0.45) keeps dying on the "CREATE TABLE ffmpeg_data ..." statement, saying "#1101 - BLOB/TEXT column 'input_file' can't have a default value".
You may want to remove the default values for text fields from that statement.

Hope that's helpful...

Flashvideo flv file is not playing

Hi All,
I have install flash video module, ffmpeg program. Everything is working fine like converting to flv and creating thumbnail. While submitting the node the video file is converting into the flv format and plays the only once after submitting. But if I go again that node after clicking the thumbnail(created by ffmpeg) it shows the blank page. I dont know whats the reason. Any help would be appreciate.

Flashvideo_views.module improvement

Hi, I added the possibility to sort videos on play_counter in views. Here are the code of the flashvideo_views.module (based on 5x-2.6-beta version. Feel free to try it.

/**
* Implementation of hook_help()
*/
function flashvideo_views_help($section = 'admin/help#flashvideo_views')
{
switch ($section) {
case 'admin/help#flashvideo_views':
$output = 'The FlashVideo Views module provides a new Field in
the Views module that allows you to see the Video or Video Thumbnail.';
return $output;

case 'admin/settings/modules#description': return t('Provides a plugin to allow Views functionality to the
FlashVideo Module.');
}
}

/**
* The views plugin for the FlashVideo module is developed and maintained
by * user mikesmullin at http://drupal.org/user/108440
*
*
* This include file implements views functionality on behalf of the
* flashvideo.module. */

function flashvideo_views_views_tables() {
$tables['flashvideo'] = array(
'name' => 'flashvideo',
'join' => array(
'left' => array(
'table' => 'node',
'field' => 'nid'
),
'right' => array(
'field' => 'nid'
),
),
'fields' => array(
'nid' => array(
'name' => t('FlashVideo: Video'),
'handler' => 'flashvideo_views_handler_video',
'option' => array(
'#type' => 'select',
'#options' => 'flashvideo_views_option_video',
),
'notafield' => true,
'sortable' => true,
),
),
'sorts' => array(
'play_counter' => array('name' => t('Flashvideo: Played
Counter'))
),
);
return($tables);
}

/**
* Views handler for displaying the video.
*/
function flashvideo_views_handler_video($fieldinfo, $fielddata, $value,
$data) {
$node = node_load($data->nid);
switch ($fielddata['options']) {
case 0: // Flash Video Player
return flashvideo_get_video($node, array());
case 1: // Thumbnail Image
case 2: // play_counter
return $node->play_counter;
default:
return flashvideo_get_thumbnail($node, array());
}
}

/**
* Views - Generate a list of options for the */
function flashvideo_views_option_video($op) {
return array(
t('Flash Video Player'),
t('Thumbnail Image'),
t('Played Counter')
);
//return $a;
}

Suggestion and a Bug

Hi, flashvideo is a great module. Thanks for developing !

I have a suggestion for the automatic import via video_import directory.

I think the import should not set the videos automatically to "published" after rendering the video, since the author may want to, change the title, edit the node text before publishing the video. It would be great if the module would grab the default settings (Publish settings, Comment settings) of the node type settings.

I think i also found a bug. Selecting the node type for the automatic import seems to only work correctly when you enable flashvideo support for at least 2 node types. Otherwise it does not save video with the correct node type and falls back to the default node type specified in the module source code.

Modifying the source

Hello there,

I love the FlashVideo project because of it's automation and simplicity.

However, as I have my video blog on my own home server, I have a pretty bad upload speed. What I'd want to know is that would it be possible to do this: After converting the video file to flv, it gets uploaded to a specified ftp site (external) and then it gets linked to the post.

This would make the videos buffer/load way faster, but I could still have it on my own server. I have access to hosted ftp, but I'm simply wondering if there's an easy way to accomplish this, or if I need to dig into the code?

Thank you!

- Dids

Its awesome

I know!

its so awesome the way the Video loads so much faster than the original ones

FFMPEG hosting News

Not at all... The video

Not at all... The video import directory was put into place to solve this and should just work with the latest version of the FlashVideo module.... First, just create a directory in your files directory called "video_import". Make sure the permissions allow for reading. Then FTP any video that you want to add to your site into that directory, run cron, and yiola! You should then be able to go to your content section and see that some new nodes were created with those videos you uploaded via FTP. You can then change the node type in the Global FlashVideo Settings.

Enjoy!

Actually, the problem here

Actually, the problem here is that I am using two different servers. One that I maintain at home, which is where the videos get uploaded and converted, but then I have a domain at GoDaddy, but it has no ssh and no ffmpeg.

What I'd like to do is simply store the FLV files on the GoDaddy domain, and fetch them via the drupal on my home server (where the original videos get converted).

This way the buffering would be smooth, even if the site (home server) was under heavy traffic. Basically GoDaddy would only serve as a file storage for the already converted flv's.

The biggest problem with the video_import module was that it was also used to convert the videos, but as my current GoDaddy plan can't handle that, I have to let my home server do it.

Thank you!

- Dids

Hello

Hello

First of all, thanks for your walkthough! I am an absolute newbie (hosting on Dreamhost.com) and have little knowledge in terms of server administration. Anyway, I did everything, and yet it keeps saying "no video availble" even if I manually run the cronjob.

have a look yourself:

http://www.tiervideos.net/?q=tracker

If anybody could help I'd be sooo glad. Feel free to register and try it out yourself (cronjobs run every 10 minutes). I'm a bit annoyed with the whole situation as I can't continue to work on my site (which is pretty poor at the moment ;-) without the flash player working.

Have you actually looked at

Have you actually looked at the output directory and see if it is actually converting the videos? If not, then I would first focus my attention on why the video is not being converted instead of why it isn't showing up in your node. Here are some reasons why the ffmpeg would fail.

  • Your output directory does not have writable permissions for all users (ie: chmod 777).
  • You do not have an mp3 codec installed for your ffmpeg (usually results in a zero byte flv file)
  • You have the wrong path specified for ffmpeg (In the FlashVideo settings, verify that your host path is /usr/bin/ffmpeg

Tracking User views

My client wants to track video plays by user. I think it could be done with Google analytics: http://www.google.com/support/googleanalytics/bin/answer.py?answer=55520...
but this looks like it would involve hacking the player.

Can you think of a easier way to do this?

That, or you can add a new

Help!

I've downloaded your flashvideo 4.7.x-1.0 at drupal.org. I bypasseed your step 1 because I dont have FFMPEG and I only inted to upload .flv files.

The problem is I can't get it to run on a page content. Do you have any guide in installing it in drupal 4.7?

Thanks

FlashVideo Thumbnails

Hi Travis,

Great work on this module btw. Love it! I have a question, maybe you can help.

I've uploaded 10 movies to my site, successfully. Thumbnails worked and all display beautifully. Here's the rub. I've decided I don't like the 2 second thumbnail clipping, so I extended it to 20 seconds. Now, I'm stuck. How do I get the module to re-thumbnail the videos? Please don't tell me I have to re-upload them.

If there is an easy way to do this, I would love to know how.

Peace!

Do you SSH access to your

Do you have SSH access to your account? If so, then you can just use a program like Putty to do it manually by typing in the ffmpeg commands in your shell prompt. OR... Do you know PHP? If so, then just write a manual script that goes and re-creates these thumbnails. Thats what I would do... OR... You could just re-upload them... :)

The long awaited thank you...

I figured as much... I think I was hoping there might be a built-in feature or a few functions I could call from php.

Thank you for the suggestions. I'll avoid the re-upload! :-)

Flash videos dont display

Your tutorial is great, i joined cirtex as per your recomendation on your site following your link. I downloaded flash video module and install it and enable it for content type page.
The settings are as follows;
ffmpeg settings;
ffmpeg command: -i @input -f flv -acodec mp3 -ar 22050 -ab 64 -ac 1 @output
ffmpeg path: /usr/bin/ffmpeg
out put directory : /files
flash player settings:
player name: flvplayer.swf (i renamed it from player.swf cuz the flash player which resides in the files directory is called flvplayer.swf so i didnt chaneg that)
The location of flashvideo_playlist.php is the main directory where the 'sites' and 'file' directories are.

Now when i a create a new page and attach a video to it and upload it, and run the cron job, it apperas in the file directory with .flv extension, which means that the conversion is ok. But the converted size is actually larger than the original. The other problem is that when i check out the page, the page is there but the video doesnt appear.
Any help with this will be greately appreciated.

Which version of FlashVideo

Which version of FlashVideo are you using?

If it is version 1.7, then your output directory shouldn't be /files. I changed this so that it will go off of the system files directory (which defaults to files). If you are using version 1.7, then change this to videos, or in your case, just leave it blank.

Also, try this....

Actually go to the following URL and tell me what it tells you... http://www.yoursite.com/flashvideo_playlist.php where you would replace http://www.yoursite.com with whatever your website url is.

Thanks,

Travis.

your really throwing some people and me double standards

The output directory is where your files go... it should default to files, but you can change it in the FlashVideo Settings to be any subdirctory of this folder.

this one of your post now you make another statement calling yet some new dir now maybe you can understand why I am so heated with this application. As to what version ? 1.7 how many versions is their and where the hell are they. why not REMOVE all the old stuff and not clobber up the net with useless information that gets people like me upset after hours of reading.
Travis I really mean you do disrespect but the topic on this module is by far the worst I have ever seen as to what is really the subject matter and what really applies and where and when. Given the fact that I have had so much trouble with this my first reaction is the trash drupal and find another product based on a what would seem to be a simple module installation.
Now if my harsh words has offended you that is NOT the intent I am just sick and tired of spending an entire day chasing my tail.
spike

All the urls are displayed

It displays all the urls of the videos that i have in files,,,
Its some thing like- http://mysite.com/files/4_simpson.flv on a blank browser page.

Ok, good.... That's what it

Ok, good.... That's what it is supposed to do.
Now look in your files directory and make sure those files are there.... Also verify that your FlashPlayer.swf is in that same directory.

Thanks,

Travis.

extra files folder

mysite.org/files/files/9_Default.flv

my flashvideo_playlist.php page shows an extra files folder in my playlist. The 9_Default.flv is in the files directory of my Drupal root. flvplayer.swf is in the files dir also. I assume my video isn't playing because the playlist thinks these two files are in files/files/?

I am sure this is a quick fix, I just don't know where to fix. Thanks...

Make sure that the output

Make sure that the output directory in the FlashVideo settings does not include the "files" directory. This should be done in the system configurations. The FlashVideo settings output directory is just supposed to specify a directory within the files directory. For your case, it should be blank.

Thanks,

Travis.

What an idiot

How silly, I forgot to set the name of my flash player...
Ok, my FlashVideo settings did have a blank for the output dir. My problem was that I still had the default Player.swf instead of flvplayer.swf in my player settings. Even though my playlist still shows /files/files/myvideo.flv...

My only problem now is that in the headline it shows the [video] tag but no thumbnail. When I go to the actual node page the full video plays as anyone would want it to... perfectly. How do I get the thumbnail to show in the headline part.

Great product by the way... I will be making the donation if I can ever find a place to send my thanks. Do you do paypal?

I just added a Donate Tab at

I just added a Donate Tab at the very top of the screen. Thanks for your support! Please let me know if you have any other problems.

Thanks,

Travis.

Yes travis, they are there.

All the files that appeared on the browser page, when i entered http://mysite.com/flashvideo_playlist.php are there (in the files directroy), and the flvplayer is also there......Dont know whats wrong here?
One more thing, when i type video in the body area, its ok but when [video], is typed, i receive the following error message;
warning: strpos() [function.strpos]: Offset not contained in string. in /home/kalelcom/public_html/modules/flashvideo/flashvideo.module on line 808.

And upon checking, the line 808 of flashvideo.module looks like the following;
while(_flashvideo_parse_param($body, $pos, $params)); // Parse all the parameters.

I hope this can clarify the issue a bit.

Thanks.

How to install the Flash Video Module

Sorry for sounding really thick here. My first day using Drupal and have to get the flash Video Module up and running.

You state to install the flash Video module but do you have any documentation on this ( as I can't seem to find any)?

Thanks a million

not to worry I think I have got it

You install the module by

You install the module by just copying the contents of the tarball that you download from the website, and then just placing the directory called flashvideo in your modules directory. Then you can go to Administer >> Site Building >> Modules. You should see the FlashVideo module in that big long list. Check the checkbox next to it and then hit Save Configuration at the bottom.

Thanks,

Travis.

Thanks Travis

This stuff is amazing, however been thrown in feet first But having a ball with it :@)

Great modules!

upgrading to 1.7 worked well and it is a really great module. I will wait for a release to be fixed thumbnail feature. thanks.

Thumbnail feature should be

Thumbnail feature should be fixed....

The only anomaly has to do with CCK's weight is higher than that of the FlashVideo's weight which will ignore the tags [thumbnail] and [video].

However, you can fix this fairly easily by just changing the weight of the FlashVideo module (in the system table of your database) back to 10.

Thanks,

Travis.

Different behaviour (avi vs flv)

just upgraded to v1.7

upload dir: files
output dir: files
uploaded foo.flv and foo.avi
both displayed ok

changed settings
upload dir: files
output dir: files/flashvideo
uploaded foo.avi , run cron ... displays ok
uploaded foo.flv , run cron ... no output is created in output dir, no entry in ffmpeg_data

on a side note: would it be possible to have the uploaded video
deleted upon successful ffmpeg conversion?

Thank you for implementing the flashvideo module!!!

With version 1.7, I changed

With version 1.7, I changed the way the output directories work. When you specify "files" as the output directory, you are really saying http://yoursite.com/files/files/ as the path. The reason that I did this is because I needed to stay consistent with the system files path directory. If the person changes the system files directory to, let's say, myfiles, then I would need to also incorporate this change.

Have you tried leaving the output directory blank, or in your case just putting flashvideo as the output directory? This way, the real path would be http://yoursite.com/files/flashvideo (that is assuming you left the output files directory as the default "files")

Thanks,

Travis.

just tried your suggestion

just tried your suggestion (setting output dir to "flashvideo", system upload dir is "files")
and managed to create and view two pages: foo1.avi source and foo2.flv source.
Still I am somewhat puzzled, as after running cron I see 3 files only:
files/foo1.avi
files/foo2.flv
files/flashvideo/foo1.flv
I guess I cannot keep all the converted videos within output dir (and remove files/foo*)

thank you, and have a nice week end...

New!! Discussion Forums

Hello everyone. Since I have had such great response with this article. I have decided to create a forum for general discussions. If you have a question about FFMPEG, FlashVideo, or Drupal in general. Please feel free to post it there....

The comment section is getting a little hard to navigate, and the Forum structure is much easier to browse topics and questions.

Thanks!

Travis.

Is there a way to increase video conversion quality?

Are there any settings with ffmpeg that can be optimized to increase the quality of the flash movie created. In general, the movie is really blocky in nature.

I have had better results using On2 flix to replace each of the converted videos manually but prevents the scalability of the application.

Thanks

You can try manually

You can try manually specifying some of the video parameters that would normally be defaulted since they are not there. Try reading some of the documentation on the FFMPEG official website. For example, you can add the tag -maxrate to the FFMPEG command line. This changes the bitrate from 200kb/s default to the maximum. Try also adding -sameq to the FFMPEG command line. This basically states in the documentation as Use same video quality as source (implies VBR). Seems to me, though, you would have a big size penalty by doing this. But if you are not concerned with the video size, then by all means max everything out. Hope this helps.

This is great but I have a huge feature request

I got this up and running in no time at all, very nice. I am wary of using it though mainly because there is a cheaper solution for my needs though more work intensive..let me explain.
Using a dedicated host and your module with ffmpeg might be ok if I run the cron jobs when the traffic is low since its to cpu intensive to have the server encoding and serving videos to traffic.

The storage for dedicated is usually somewhat small and expensive especially if im already paying 100$ a month for something that makes no money, it would be rather easy to fill up a 10gb drive with videos.

OK heres my solution, use amazons s3 for storage and serving media files..its cheap and its on a big pipe which means speed and no downtime and it will take the load off the encoding server.
The problem is this might get complicated, user uploads--->your machine encodes the original file --->flv is sent to amazon s3--->thumbnails and video is show on your page. original file is deleted or send to s3 as backup. They charge a flat rate for storage and bandwidth.

Another even cooler option though its in beta is the amazon EC3 service which can directly accept user uploads-->encode using ffmpeg and the send it to S3 for you to use. You are charged soemthing like .10 cents per hour of dedicated cpu time, very effective for encoding.

Im not sure if your familair with all this but it would really be useful for drupal as a whole, you can check out the media_mover module http://drupal.org/project/media_mover and the drupal file group for more info and some of the problems they are facing http://groups.drupal.org/node/2383

What to you think about something like this?I'd love to help this out by providing server, testing or even donations.

That sounds like a

That sounds like a phenomenal feature. Probably a little out of scope with just this module alone. What would be great is if I could plug into the media mover module somehow to where I would take care of the video uploads, encoding, and then use the media mover module to post it to the s3 server.

I will look into this.

Thanks,

Travis.

s3

Hi Travis,

Did you get a chance to look into s3 as an utility service?

Thanks,

Jim

Haven't had much time to

Haven't had much time to look into this, but I do plan on doing it for a future release of the FlashVideo module. I will keep everyone informed on this website as to the progress of this feature. I will tell you, though, that it is on high priority for the future release of this module (or at least an interface with another module that does it would be nice).

Thanks,

Travis.

Ya it's prob beyond the

Ya it's prob beyond the scope of your module, but having yours work with the media mover would be really nice, unfortunatly no ones figured out how to do this yet without hacking a lot of stuff.
I have an amazon S3 account if you'd like to do some testing.

No upload available in nodes

I initially had a problem with 'seeing' the upload video node, but have attached it now successfully to my page node, and it works! I needed to reset and update my databases. I still am unable to create a new node and have the video upload available. I have created a "Video" content node and enabled Flashvideo for it with basic settings. When I create content with this type however, there is no Upload Video dialog.

Any ideas?

SJMO2

Partially working...new problem

I updated the module to the newest version and now see the upload within any node, now received this error:

Fatal error: Cannot instantiate non-existent class: ffmpeg_movie in /var/www1/html/modules/flashvideo/flashvideo.module on line 651

Thanks

Try disabling the FFMPEG-PHP

Try disabling the FFMPEG-PHP option in your node type... What you are seeing is if you have FFMPEG-PHP enabled, but its either not working properly or you don't have it at all on your server.

Thanks,

Travis.

Question regarding ffmpeg-php

I've read the comments regarding ffmpeg-PHP and what your module uses it for, and appreciate the clarification. I do, however, wish I could get a liiiitle bit more info about that. If I have ffmpeg but NOT ffmpeg-PHP, and therefore don't get to "extract the height and width for reference," what disadvantage will I suffer? Can you be a bit more specific? Is there any particular feature that simply does NOT work without having the ffmpeg-PHP? I guess I'm wondering where this extracted information is used and whether I'll suffer any loss of functionality if I have to uncheck that checkbox. It will help me make an informed decision about whether I must switch to a web host which has the ffmpeg-PHP compiled in.

(As a side note, do you know whether there are any drawbacks to having ffmpeg-PHP installed as an extension [under "Building as an Extension" in the ffmpeg-php page] rather than compiled into PHP?)

Thank you in advance for your help; your module is terrific and a lot of people really appreciate your efforts.

To be completely honest,

To be completely honest, FFMPEG-PHP was thrown in there on a side note... The module really never even uses it, unless your encoding attempts fail (then the width and height are used to show the default old-fashioned embeded windows player). However, with the latest release, I do believe that I have resolved most encoding problems, so you should be perfectly fine without FFMPEG-PHP. So, personally, I wouldn't waste my time worrying about it. If you have FFMPEG, then you should be ready to go with the FlashVideo module.

As for your second question... I never actually installed the ffmpeg-php, so I am afraid I am not the right person to ask. It just came standard with my hosting company.

I hoped this helped.... OH, And thanks for the compliments!