flv, ffmpeg and PHP: File conversion

Hi friends,

2 days ago I got a project in which I have to upload avi, mpeg or 3gp movie clip and convert this clip to flv as well generate thumbnail for this video. I know that this can be done through ffmpeg. But I didn,t know how haha..

Well I searched enough and start making environment for development. I did following mistakes.. I am listing those  mistakes. I am 100% sure it will save your day.

I was using Windows environment: FFmpeg is primarily made for Linux environment not for windows. Some experts developed windows version of ffmpeg.  Some functions are unavailable in windows version. SO I suggest you to use Linux environment.

I thought that only ffmpeg can do everything: FFmpeg is a command line tool to do video related task (only video) such as clipping, video conversion, frame extraction etc. But for the sound, watermarking you have to use other packages too. I will tell about these details later.

php-ffmpeg and ffmpgeg: I was very much confuse between php-ffmpeg and ffmpeg. I after 30 minutes of googling I came to know that ffmpeg-php is extension for php which provide handy functions to convert videos and if you use ffmpeg then you have to use exec() command to execute ffmpeg commands.

Step by step procedure to convert video:

1. Setup Linux system.. forget that windows can do the job!

2. follow instructions and install all required modules. here is comprehensive step by step procedure available http://vexxhost.com/blog/2007/03/03/installing-ffmpeg-ffmpeg-php-mplayer-mencoder-flv2tool-lame-mp3-encoder-libogg-%E2%80%93-the-easy-way/ . if you face any problem then you can ask me.

Remember: Installation order  LAME->FFmpeg->Ruby->FLVTool2

3. Now you have successfully setup environment. Download any example from net and run.

The  best thing I got is videotoolkit you can download it from Here . It saved my day. you can also try it. It’s really worth to try this!

Hope this article will helpful. If you still have any problem then ask.. Happy coding….

CakePHP Controller

Now let’s move further. the next part is controller. Controller has logics (some times reffered Business logic in Java). In controller you can write any logical code, such as DB queries, calculations and every thing which you can do in PHP. But remember to use cake functions to ‘Make Life Simpler’. The controller should be in app/controllers directory.

You should name controller carefully. The name of controller should be ****_controller.php (replace ****) with your controller name. You should take care about controller name because when you run any page (code) of controller you have to type http://server.com/(Controller)/(Page/Function Name).

Controller class extends AppController. If you want to add some global functions for all controllers, you can write them in cake/app_controller.php. Now lets create our first controller

class UserController extends AppController {

var $name = ‘Users’; //Name of controller
#var $layout = ‘upload’; //Default Layout for this model
//in case you want to use different layout (I will cover Layouts in next posts)
#var $uses = array(‘User’); //If you want to use more then one table (Model) then add in uses array.
#var $components = array(‘Email’); //Components to be used in this controller (I will cover components in next posts)
function index() // Default function, when called show index page. { }
}

My first cake bite – 1

Hi

In my organisation I got a project on cakephp. I nevre hrd abt any framework in php. This is my first php project in which I am using framework. I hav good experience in struts so I am expecting that it will not much hard to understand 4 me.

I have decided to write my daily progress here so that it can help those ppl who r new to this framework.

Why CakePHP?

It has many features that makes it a great framework for developing applications swiftly and with the least amount of hassle. Here are a few in no particular order:

  • Active, friendly community
  • Flexible Licensing
  • Compatibility with PHP4 and PHP5
  • Integrated CRUD for database interaction and simplified queries
  • Application Scaffolding
  • Model View Controller (MVC) Architecture
  • Request dispatcher with good looking, custom URLs
  • Built-in Validation
  • Fast and flexible templating (PHP syntax, with helpers)
  • View Helpers for AJAX, Javascript, HTML Forms and more Security, Session, and Request Handling Components
  • Flexible access control lists
  • Data Sanitization
  • Flexible View Caching
  • Works from any web site subdirectory, with little to no Apache configuration involved