Skip to main content

Posts

Showing posts from April, 2010

Convert & Calculate the length of an flv video

You can convert an flv video into a wmv video using the command line: ffmpeg -i test.flv test.wmv Through the above command, the "test.flv" video file is converted to "test.wmv" video file. Note that you need the file "ffmpeg.exe" in the folder from where you invoke the above command. And you can dynamically calculate the length of an flv video, using the function below: <?php function GetFLVDuration($file){ // get contents of a file into a string if (file_exists($file)){ $handle = fopen($file, "r"); $contents = fread($handle, filesize($file)); fclose($handle); // if (strlen($contents) > 3){ if (substr($contents,0,3) == "FLV"){ $taglen = hexdec(bin2hex(substr($contents,strlen($contents)-3))); if (strlen($contents) > $taglen){ $duration = hexdec(bin2hex(substr($contents,strlen($contents)-$taglen,3))) ; return secondsToWords($duration/1000); } }

OOPS way of querying database !!!

Tired of writing those connect and execute query statements in php all the time ? Now you have got an OOPS way of executing your queries... Using this, there are many advantages like avoiding the reuse of code and improvement in performance. Supose we have a user table with the fields id, name, branch and city: CREATE TABLE IF NOT EXISTS `user` ( `id` int(2) NOT NULL auto_increment, `name` varchar(25) NOT NULL, `branch` varchar(25) NOT NULL, `city` varchar(25) NOT NULL, PRIMARY KEY (`id`) ) Dump few values into it: INSERT INTO `user` (`id`, `name`, `branch`, `city`) VALUES (1, 'ravi', 'CSE', 'Hyderabad'), (2, 'kiran', 'Mech', 'Vijayawada'), (3, 'prasad', 'CSIT', 'Vizag'), (4, 'sashi', 'ECE', 'Tirupati'); Now to perform the task, the following are the steps: 1) First create a config file with the details of the constants like: host, username, password, database name and all the tab