This is basically the continuation from Installing MAMP and Drupal on OS X and thats why the numbering continues at 3. Anyway lets get started.
3) INSTALLING FFMPEG & FINK on OSX
FFmpeg is a collection of software libraries that can record, convert and stream digital audio and video in numerous formats. It includes libavcodec, an audio/video codec library used by several other projects, and libavformat, an audio/video container mux and demux library. The name of the project comes from the MPEG video standards group, together with "FF" for "fast forward". Along with other plugins it will convert any video format to the Flash format. Basically its a fast, accurate multimedia transcoder.
If u want FFmpeg to set up an automated, web based system to transcode a variety of input video formats to the Flash video format, which can easily be displayed on the web. It will be necessary to approach FFmpeg as a command-line Unix like tool. You will need to learn the installation techniques commonly used by open source projects, and the starting point for your work will be running the Terminal and working mostly from the command line.
Before you can follow these instructions, you must install Apple's Developer Tools.
3.1) Prerequisites: lame
LAME is a free software application used to encode audio into the MP3 file format. The name LAME is a recursive acronym for LAME Ain't an MP3 Encoder, reflecting LAME's early history when it was not actually an encoder, but merely a set of patches against the freely available ISO demonstration source code
MP3 is the only commonly available audio format used with Flash video, so you will need an MP3 encoder. FFmpeg doesn't include one, but it will use LAME, which creates good quality audio files, if you install it. Header files will be needed during the compile, so it is not enough to install a prebuilt binary using a package manager. Instead follow these directions to compile it from source:
3.1.1) Start by creating a working directory:
mkdir ~/lame
cd ~/lame
3.1.2) Download the latest source code release of LAME from Sourceforge http://sourceforge.net/project/showfiles.php?group_id=290
The file you want will be named lame-3.97.tar.gz or something similar.
3.1.3) Download the tar file, you need to unpack it as follows
tar xvzf lame-3.97.tar.gz
3.1.4) Move the lame-3.97 folder into the lame folder you created. (with this one you could also unpack it graphically however as you will see later there are certain packages where you cant so I always think its good to get used to doing things the right way in the Terminal.)
3.1.5) After downloading and unpacking the source, change to the main directory and then enter the three commands which are typically used to install open source projects:
cd lame-3.97
./configure
make
sudo make install
Each command will take a minute or so to complete. You should keep an eye out for any errors which may occur, but its generally straight forward enough
3.2) FAAC and FAAD
FAAC stands for Freeware Advanced Audio Coder.
FAAD stands for Freeware Advanced Audio De-coder.
Since Quicktime commonly uses AAC for audio, you may want to encode and decode that format. Here again FFmpeg doesn't include built-in codecs, but it will use the codecs provided by another open source project if you install them first.
3.2.1) Download the latest releases of FAAC & FAAD from http://www.audiocoding.com/downloads.html
3.2.2) First create a folder for FAAD.
mkdir ~/faad
~/faad
3.2.3) To install faad if you downloaded the tar then :
tar xvzf faad2-2.6.1.tar.gz
if it was a zip then it will uncompress to a folder
3.2.4) Now move that folder (called faad2)into the faad folder you just created.
3.2.5) now to install FAAD enter in the following commands
Cd faad2
./bootstrap
./configure
make
sudo make install
3.2.6) Now to install FAAC. Follow the last procedure to unpack it.
3.2.7) Move the extracted faac folder to ~
3.2.8) Now to finish installing faac enter in the following commands:
Cd ~/faac
./bootstrap
./configure
make
sudo make install
Building FFmpeg for Mac OS X
It's best to run a recent version of FFmpeg, which means downloading the source code from the Subversion repository. This isn't too difficult, but there are some prerequisites that you may not have if you're not in the habit of compiling software from source.
In particular, you need a Subversion client, and since the easiest way to get Subversion is probably to install it via Fink, you also need Fink.
The goal of the Subversion project is to build a version control system that is a compelling replacement for CVS in the open source community. The software is released under an Apache/BSD-style open source license. Subversion (SVN) is a version control system initiated in 2000 by CollabNet Inc. It is used to maintain current and historical versions of files such as source code, web pages, and documentation.
Many well-known open-source projects use Subversion for managing their files, including: Apache Software Foundation, KDE, GNOME, Free Pascal, GCC, Python, Ruby, Sakai, Samba, Mono, and ePresence Interactive Media. SourceForge.net and Tigris.org also provide Subversion hosting for their open source projects, Google Code and BountySource systems use it exclusively.
Subversion is also finding adoption in the corporate world. In a 2007 report by Forrester Research, Subversion was recognized as the sole leader in the Standalone Software Configuration Management (SCM) category and strong performer in the Software Configuration and Change Management (SCCM) category.[1]
Subversion is released under the Apache License, making it free software.
3.3) Fink
Fink is a package management system that aims to bring the full world of Open Source software to Darwin and Mac OS X. The Fink project is an effort to port Unix programs to Mac OS X. Fink uses dpkg and APT (Debian's package management system), as well as its own frontend program, fink (which is implemented as a set of Perl modules).
Fink features a binary distribution for quick and easy installation, as well as a source distribution for users preferring more flexibility. In addition to command-line tools for handling packages, FinkCommander provides a GUI.
Fink is not compliant with the Filesystem Hierarchy Standard, as it stores all its data in a hierarchy rooted at its own directory, "/sw" by default, rather than as part of the base system or under "/usr/local".
With the help of dpkg, it maintains a separate directory hierarchy. It
downloads original source releases, patches them if necessary, configures them for Darwin and compiles and installs them. The information about available packages and the necessary patches (the "package descriptions") are maintained separately, but are usually included with this distribution. The actual source code is downloaded from the Internet as necessary.
The source tarball contains the fink package manager. After you have installed it, you will be able to get package descriptions and patches. It will use these to download the source code from the original distribution sites or the Fink project's mirrors and build them on your local machine. Note on leopard we need to get the source and build it.
3.3.1) Download fink-0.27.8 - 1292K, .tar.gz format from http://www.finkproject.org/download/srcdist.php
IMPORTANT-Do Not extract the archive with StuffIt, it will corrupt some file names. Use the command line tar utility instead.
3.3.2) Assuming you downloaded the .tar to your desktop run the command
Cd ~/Desktop
tar xvf fink-0.27.8.tar
this will then extract the content to a folder called fink-0.27.8 on your desktop.
3.3.2) Move the fink folder from your desktop to ~/
3.3.3) Now enter in these commands
Cd ~/fink-0.27.8
./bootstrap /sw
3.3.4) You will then be asked to choose a method.
Choose sudo
enter in your password
3.3.5) for the following questions just press return to accept the defaults until it asks for your Continent.
Choose [4] Europe (if your in Europe etc)
Choose [38] United Kingdom (or whatever country your in)
3.3.6) Now continue pressing Enter to accept the defaults for the update locations & Repositories.
Once you have accepted the defaults for a few more settings the installer will continue. It will start to download packages from the internet using curl.
Sometimes the first address it connects to will not be working and you will see this at the command line as nothing will be transferred.
After a short time if this happens you will be asked if you want to give up or try another mirror from your location, select try another mirror, then you will see it starts to download files. The mirrors etc will also be updated and you will be asked if you want to change your choices, type in Y and accept everything again.
The installer will now continue, this will take considerable time (sometimes 30mins or more) and at times will pause and seem as if it is not doing anything. Don’t worry just leave it alone and let it do its thing.
3.3.7) Run '. /sw/bin/init.sh' to set up this terminal session environment to use Fink.
3.3.8) Enter in the following commands:
cd /sw/bin
./pathsetup.sh
3.3.9) Click ok on the windows that pop up.
Note - To make the software installed by Fink available in all of your future terminal shells, add '. /sw/bin/init.sh' to the init script '.profile' or '.bash_profile' in your home directory. Also you can add it to your $PATH. To see your current path type echo $PATH at a command prompt. The program /sw/bin/pathsetup.sh will set this up anyway but its handy to know if you get any problems)
You still need package descriptions if you want to compile packages yourself. You can get them by running the command 'fink selfupdate'.
3.3.10) Run the command:
fink selfupdate
Choose rsync
3.3.11) Now enter the command:
fink update-all
3.3.12) Now Open a new Terminal.app window and run the following:
fink scanpackages; fink index
Note – If you want you can also use the included Fink Commander GUI application (which must be placed in a real folder on your system, not run from the disk image) and run the following commands from its menu: Source->scanpackages followed by Source->Utilities->index.
You should now have a working Fink installation in '/sw'.
You can now remove the ~/ fink-0.27.8 directory if you wish.
Note - After you have installed fink and the other base packages, the commands fink selfupdate-rsync or fink selfupdate-cvs will download the package description files and patches.
3.4) Downloading and installing FFMPEG
3.4.1) Now that you have Fink installed, use these commands to install the Subversion client:
sudo apt-get update
sudo fink install svn-client
accept all the defaults and let it continue
Note - This will also take quite a while so just go and have lunch (it will take nearly that long) or something and let it do its thing.
3.4.2) You are now ready to fetch the source with Subversion. First create a working directory:
mkdir ~/ffmpeg
cd ~/ffmpeg
The up-to-date version of FFmpeg generally compiles cleanly, and that is the version you usually will want:
3.4.3) Now enter in the following commands:
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
cd ffmpeg
3.4.5) Next you will need to configure and make:
./configure --enable-libmp3lame --enable-libfaac --disable-vhook --enable-shared \--disable-mmx
make
sudo make install
Note - The --disable-mmx flag is not required on a PowerPC. If you leave it out on an Intel Mac, you will probably get a compile error, but it's worth trying since it will provide a speed boost. As u installed the AAC codecs, the --enable-libfaac flag is added.
Testing FFMPEG
FFmpeg is now installed. There are instructions in the doc/ directory, but basic commands are quite simple. You can now convert video from the command line. To convert an mpeg video to Flash, use:
ffmpeg -i video.mpg -ar 22050 video.flv
Note- The "-ar 22050" flag sets an audio sample rate of 22050 Hz. It is usually necessary to set a sample rate when encoding flv files because the MP3 encoder only supports rates of 11025, 22050, and 44100 Hz.) That's the basic idea, but in practical uses you will probably want to take control over more of the quality settings. A more realistic command would look like this:
ffmpeg -i video.mov -b 600k -r 24 -ar 22050 -ab 96k video.flv
where
"-b 600k" selects a video bitrate of 600 kilobits per second. This is a compromise between quality and bandwidth (with older versions of FFmpeg you would use "-b 600". Type "ffmpeg -h" to check which units are expected in your version);
"-r 24" selects 24 video frames per second;
"-ar 22050" selects an audio sample rate of 22050 Hz, which is sufficient for voice;
"-ab 96k" selects an audio bit rate of 96 kilobits per second; you could go a little lower for voice-only audio.
These are the parameters you will adjust most often. Finding the perfect values for your material is a matter of experiment.
4) Setting up the php.ini file for flash video
One of the most overlooked things when setting up the FlashVideo module, is preparing your web server to allow for the type of uploads required to make the module run... namely videos!
In order for the FlashVideo module to work according to design, some parameters need to be set in your php.ini file or the root .htaccess file. These parameters are as follows...
post_max_size - The maximum allowed POST size. Must be greater than or equal to Maximum Upload Size.
upload_max_filesize - The maximum allowed file upload size.
max_execution_time - The maximum allowed time (in seconds) that a script is allowed to run. Needed for long file conversions.
max_input_time - The maximum time (in seconds) a script is allowed to parse input data, like POST, GET and file uploads. Needed to keep large uploads from timing out.
The following shows the recommended values for these parameters.
Recommended Settings for php.ini:
post_max_size=100M
upload_max_filesize=100M
max_execution_time=1000
max_input_time=1000
I have included this incase you need to change the settings at a later date and you don’t have access to the php.ini file. If you do not have access to the php.ini file, then you can easily change these settings in the .htaccess file in the root of your Drupal installation. However, with this file, you need to provide these parameters by using the php_value parameter followed by the parameter name and then the actual value.. These parameters can be specified like the following.
Recommended Settings for .htaccess file:
php_value post_max_size 100M
php_value upload_max_filesize 100M
php_value max_execution_time 1000
php_value max_input_time 1000
Anyway here we go!!!!!!!
As i have access we will be changing the php.ini file. Now remember im using php5. If you changed the default settings and are using php4, then the correct php.ini files will be in the php4 folder.
4.1) Open /Applications/MAMP/conf/php5 folder
4.2) Edit the php.ini file in this folder with these settings:- (these setting can be higher it depends how big the files we wish to allow the user to upload.)
post_max_size=100M
upload_max_filesize=100M
max_execution_time=1000
max_input_time=1000
4.3) Save the file and exit your text editor.
5) Getting the flash video module
Ok, so now you've got a server with FFMPEG, you just installed the latest revision of Drupal 6.
5.1) To get Flash Video into your website, you will now need to get the conveniently named FlashVideo Module. Download the flashvideo-6.x-1.1.tar file
http://ftp.drupal.org/files/projects/flashvideo-6.x-1.1.tar.gz
5.2) Extract the file (using either tar or Stuffit or Archive expander the choice is yours)
5.3) Move the extracted folder called flashvideo into /Applications/MAMP/htdocs/sites/all/modules
Further info about the flash video module for interest only
In order to be truly 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 (without spaces in between the []).
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 multiple 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.
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.
6)Get Player.swf
6.1) OK, now you can create your own Player.swf (which will be a tutorial i write on here later). Then put it in the /Applications/MAMP/htdocs/files directory
Or if you want a free one for non commercial use then, simply follow the following link to download a Flash Player from http://www.jeroenwijering.com/upload/jw_media_player.zip
Now that you have downloaded the Flash Player package, there is really only ONE file within that entire download that we are interested in, and it is called mediaplayer.swf, but the default for the FlashVideo module actually uses the name Player.swf. So, the first step that you will need to do is rename the mediaplayer.swf file to Player.swf and then place that file in root files directory of your Drupal installation. Any sub folders containing videos will then just reference that single player in that root files directory... And that's it!! You are ready to move on!
7)Change flash settings in drupal and create a page.
7.1) First change permissions on /Applications/MAMP/htdocs/sites/default so that the everyone group has read only.
7.2) Go to Administer>site building>modules
7.3) Tick the 3 flash modules and click save to enable the flash modules.
7.4) Go to Administer->Site Configuration->File uploads.
7.5) Change maximum file size per upload to 32MB or whatever the biggest video size you want to allow.
7.6) Click save configuration
7.7) Create a hard link in /usr/bin for ffmpeg by entering the commands:
Cd /usr/bin
ln ~/ffmpeg/ffmpeg/ffmpeg ffmpeg
Ok, here's the fun part! Now that we have everything in place to submit, convert, and view our video, lets create a node that will actually do it! We need to first enable the FlashVideo module for whatever node type in the Drupal system. We will just make it easy and enable the FlashVideo module for the Page node type.
7.8) Go to Administer->Site Configuration->FlashVideo Settings, and then select the link that says Global settings.
7.9) Tick Enable the FlashVideo for this node type
7.10) Tick Change Node Status after Conversion.
7.11) Tick convert videos immediately
7.12) Change the video import directory so it says /files in the text box (this is very important else your content will go into htdocs)
7.13) Click the FFMPEG settings link at bottom of this page
7.14) Untick Use FFMPEG-PHP to extract video information.(if its ticked)
7.15) Change the ffmpeg command line in the text box to read
-i @input -f flv -ar 22050 -ab 64k -ac 1 @output
(Depending if you have mp3 installed etc)
7.16) The ffmpeg path text box should have
/usr/bin/ffmpeg
7.17) Tick log conversion data.
7.18) Leave everything else as default ie original directory and output directory should be blank.
7.19) Click save configuration
7.20) Go to Administer->Site Configuration->FlashVideo Settings
7.21) Select the link that says FlashVideo Settings for this node type next to the Page node type.
7.22) Once you are in there, you will want to check the box that says Enable the FlashVideo for this node type. And thats it! You are ready to go.
Let's now create a page by clicking on the link that says Create Content, and then click on Page. You should notice that the upload module now sits at the top of the page, and has been renamed to "Video Upload". So, let's do just that.
Select a video from your local hard drive, and then hit Attach. You will then see the gif progress bar image show up, telling you that your video is uploading. While it is uploading, lets place our Video tag in the Body of the node. When the video is finished uploading, then hit Save at the bottom of the form.
All Finished