Categories
PHP

Converting Videos Using PHP

In fact, video conversion on the server side is done by other softwares. PHP itself is used as a medium for the task maximum times.

We have a nice command line tool named “ffmpeg” to convert videos. I am currently working on a youtube video conversion tool and using ffmpeg to convert the videos from “.flv” to my desired format.

On my linux machine this simple command is enough to convert a “.flv” video to “.mpg” :

Using php, I do the same. PHP has a function shell_exec() that lets you execute any shell command from PHP. So, this is what I do from PHP:

That does the job for me 🙂

Categories
Personal Work

Twitter Bot Earns Me Money :)

Well, this came up as a pleasant surprise to me when I logged into my GetAFreeLancer.com account to deactivate the email notification. I have earned $34.2 in August 2009 from affiliate activity. I was puzzled first and then checked out the whole thing. One of the people whom I referred to GAF, created two projects there and I got the commission.

I am quite active on scriptlance and was getting bored with GAF for their very frequent email notification. Finally, I decided to turn off the notifications and deactivate my account. But now that GAF is earning me money from referrals, I am quite happy with them.

The referral links are being spread over the microblogsphere by my twitter bot that collects direct links to available projects on GAF and tweets them. I set up the bot out of experimental purpose but now it looks like it’s gonna be a good money maker as well.

Being inspired by this little surprise , I made some upgrades to the bot. The bot now adds hash sign (#) before important key words to make it search friendly. I also activated a identi.ca and a friendfeed clone of the same bot.

I am thinking of selling this entire bot script at $30. Anyone interested? Bargaining allowed for sure ;-).

Categories
PHP

Archiving Remote Files Using PHP

We can easily archive remote files on our server and put the archive for download by our users.

Here’s a code snippet:

It uses the ZipArchive built in class of PHP to archive the target file which is stored on a remote host. It reads the remote file using “file_get_contents()” function and uses the “addFromString()” method of the ZipArchive object to add the data as a local file inside the archive. The first parameter of this method is the name of the file which will be inside the archive. This file is usually called “local file”. The second parameter is the file contents in raw string format. Instead of the file_get_contents(), we could use alternative fopen(), fread() or fgets() functions to get the file contents as string. But when we have better and quicker solution, why should we go for complex ones ?

Enjoy 🙂