Encoding of images to videos and Upload to web using PHP

29 12 2010

Web programming was never my cup of coffee. Its been always a black-box, which works just some how and should not be tested how :D. As part of my assignments, i was given the “black-box” task of converting a set of images into video, as if that is not enough also have to connect some how to youtube and upload the the account of the users choice.

The best part being all of this needs to be done in Silverlight. This was the first time i was getting to know we could even do programming in silverlight :D. So with the task assigned it was time to execute the unknown. After a bit of consultation with the programmers best friend “the Google”, figured out its easier to use PHP for this process rather than Silverlight. Also Silverlight does integrate with well with PHP .

The encode i chose for the my assignment was the FFMPEG. The advantage of this program other than it being free is that, its cross platform compatible and also all the features of the program can be accessed and manipulated via command line. This is the feature i plan to use as i dint have much time to go into actual video encoding programming. In-order to make sure the images are read in the correct sequence to make into video, the images get named in a specified sequence. Mostly numbers starting from 0, 1 and so on. This is easier to be read from ffmpeg command line method.

The following code can be used to convert images to videos

ffmpeg -r 10 -b 1800 -i %03d.<image_extension> <video_name>.<video_extension>

Where 10 specifies the frame rate , 1800 denotes the bit rate and the images are read in the sequence of 000.jpg or 000.png etc to 001.jpg , 002.jpg etc. This simple one line code would provide with the video in the folder in the same folder.

Next was the video uploading part.  Zend framework provides excellent support when it comes to Video processing with YouTube. The installation of the frameworks is also pretty straightforward.


Step 1: Download Zend Framework

Step 2: Add the path of the Zend library to the “php.ini”

Step 3: Enable openssl.dll in “php.ini”

Step 4: Restart server.

And that would be only step up required to install Zend. The samples present along with the Zend provide the code for video upload to YouTube.




Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: