i came to know how this could be done.
Following code snippet can be used to extract a segment of video.
$inputFile = "melt.mpg";
$outputFile = "melted.flv";
//-ss is the start time in HH:mm:ss
//-t is the end time in HH:mm:ss
system("path-to-ffmpeg/ffmpeg -i $inputFile -ss 00:00:03 -t 00:00:08 $outputFile");
And that's it.