Preparing Ffmpeg to convert Video
If you want to convert Video from one format to another then you can use the FFMPEG tool to do this. We are going to take the very common example of converting uploaded video files into FLV format. This allows us to use those videos in an open flash style player so our website visitors can click an view a video. The kind of tools we'll need to do this are.
- Ffmpeg
- Ffmpeg wrapper module
- Media Mover module
Installing Ffmpeg to work with Drupal
To convert video from attachments into flv format on your Drupal installation, you will need two extra elements;
Ffmpeg is a standard open source package for multimedia handling available on many distributions so ask your host if you dont have it. Note it might be very tricky to make it running:
- Standard debian package is striped from proprietary formats so you will not be able to transcode from/to avi, mp4, rm flv or mp3 but developer of Media mover is providing static binary. You still need vhooks libs installed (part of ffmpeg) on system.
- Usually shared hosts don`t let your php files run shell commands. If you run into passthru limit or php error 127, it means you are in shell jail. Explain to your host what you are going to do and ask for a solution, this doesn't help, then you may need to change your host.
- If your test transcode is not running, try "flush all caches" from admin menu. This helped us when we ran into trouble.
Ffmpeg Wrapper
To transcode in drupal you need to install ffmpeg wraper module and test it via settings in admin menu. Best way to test is to trans code small video file with common extension like 3gp or avi and media encoded with popular codec. The Extension of the test file has to match one from list available formats of ffmpeg, other wise your test will fail (for example .mpg files may not work).
What follows are the instructions from the README.txt file that comes with the Ffmpeg Wrapper module.
Go to admin/settings/ffmpeg_wrapper
Make sure you configure the path to FFmpeg. This is relative to the root of your server. If don't know where FFmpeg is installed and you have access to the command line of your server, you can run:
$locate ffmpeg
This should hopefully give you a path to ffmpeg. If you need install FFmpeg, there are instructions here for installing it on a debian/ubuntu environment: http://www.24b6.net/?p=188
If you need a compiled binary, check http://mediamover.24b6.net/ffmpeg
If you are having PHP issues with openbasedir, you may want to look at this page: http://drupal.org/node/82223
DEVELOPERS
ffmpeg_wrapper supports defining configurations that set default values in forms that are built to support ffmpeg_wrapper. Look in the conf dir for an example of how these configurations can be built. This is helpful for constraining users from building configurations that ffmpeg will not function with.
To enable the support in your forms, merely call this function: ffmpeg_wrapper_enable($prefix, $output_form_id);
Here, $prefix is a prefix used in your forms (in standard drupal, this will be at least "edit-"). $output_form_id is the name of the output controler form element. Check out media mover API's mm_ffmpeg module for an example.
The second piece that needs to be done is to name your form elements with the ffmpeg_wrapper convention. Any form element that controls an aspect of ffmpeg (eg, audio bit rate) needs to be named in a specific way: ffmpeg_audio_ab
Where ffmpeg is always used, audio is for audio options (video is the other possibility) and ab is the ffmpeg command for setting the audio bit rate. Again, mm_ffmpeg offers a good example of how to do this.
Alternatively, you can just use $form[] = ffmpeg_wrapper_configuration_form($prefix, $configuration) to build a form from ffmpeg_wrapper. You will need to handle your own validation and submission, but outside of handing the size:other options, this is very easy. Going this route gives you the ajax form configuration straight away.





