Found the answer,
To find the extension of the file best way is to use path_info for both local files and url.
$info = pathinfo($filename);
$basename = $info['basename'];
$ext = $info['extension'];
create an array for the mime type
$mimeTypes = array("mp4" => "video/mp4");//
--> See Example here and Here
//get the mime type for file
$type = isset($this->mime_types[$ext]) ? $this->mime_types[$ext] : "application/octet-stream";
Above code works for both url and local files.
Note :
Those struggling with CDN mp4 video mime type video/mp4 issue - I had made a change in my class.s3.php file -> in mime_type[] array and also cross checked with putObject() function.
Setting of mime type is always done in coding side and not in AWS S3 bucket, We need to use
AWS PHP Class file or sdk
to do the manipulation in mime type or make the necessary changes in core class file (eg. class.s3.php )