How to create Amazon EC2 Instance

  1. Open the Amazon EC2 console at
  2. From the console dashboard, click Launch Instance.
  3. The Choose an Amazon Machine Image (AMI) page displays a list of
    basic configurations called Amazon Machine Images (AMIs) that serve as templates
    for your instance. Select the 64-bit Amazon Linux AMI. Notice that this
    configuration is marked “Free tier eligible.”
  4. On the Choose an Instance Type page, you can select the hardware
    configuration of your instance. The t2.micro instance type is selected
    by default. Alternatively, select All generations from the
    filter list, and then select the t1.micro instance type. Note that these
    are the only instance types eligible for the free tier.


    T2 instances must be launched into a VPC. If your AWS account supports EC2-Classic
    and you do not have any VPCs, the launch wizard creates a VPC for you. Otherwise,
    if you have one or more VPCs, click Next: Configure Instance Details
    to select a VPC and subnet.

  5. Click Review and Launch to let the wizard
    complete the other configuration settings for you.
  6. On the Review Instance Launch page, under Security
    , you’ll see that the wizard created and selected a security group for
    you. Instead, select the security group that you created when getting set up using the
    following steps:

    1. Click Edit security groups.
    2. On the Configure Security Group page, ensure the
      Select an existing security group option is
    3. Select your security group from the list of existing security groups,
      and click Review and Launch.
  7. On the Review Instance Launch page, click
  8. In the Select an existing key pair or create a new key pair dialog
    box, select Choose an existing key pair, then select the
    key pair you created when getting set up.

    Alternatively, you can create a new key pair. Select Create a new
    key pair
    , enter a name for the key pair, and then click
    Download Key Pair. This is the only chance for you to
    save the private key file, so be sure to download it. Save the private key file
    in a safe place. You’ll need to provide the name of your key pair when you
    launch an instance and the corresponding private key each time you connect to
    the instance.

    A key pair enables you to connect to a Linux instance through SSH. Therefore,
    don’t select the Proceed without a key pair option. If you
    launch your instance without a key pair, then you can’t connect to it.

    When you are ready, select the acknowledgment check box, and then click Launch

  9. A confirmation page lets you know that your instance is launching. Click View
    to close the confirmation page and return to the
  10. On the Instances screen, you can view the status of your instance. It
    takes a short time for an instance to launch. When you launch an instance, its
    initial state is pending. After the instance starts, its state
    changes to running, and it receives a public DNS name. (If the
    Public DNS column is hidden, click the
    Show/Hide icon and select Public

Amazing things with FFMPEG Library

FFMPEG is a complete, cross-platform solution to record, convert and stream audio and video. This is available for all the kind development(i.e. Android, iPhone, Web etc)

Below are the advanced things that can be done in FFMPEG:

Add Text in center of Video:
ffmpeg -i temp.mp4 -vf drawtext="fontfile=verdana.ttf: \ text='Aftab Muni...': fontcolor=white: fontsize=14: box=1: boxcolor=black: \ x=(w-text_w)/2: y=(h-text_h-line_h)/2" -codec:a copy output.mp4

Add text on top-left which will blink:
ffmpeg -i temp.mp4 -vf drawtext="verdana.ttf:fontcolor=white:x=100:y=x/dar:
enable=lt(mod(t\,3)\,1):text='blink'" -codec:a copy output.mp4

To flip video horizontally:
ffmpeg -i temp.mp4 -vf "hflip" temp_out.mp4

To Add logo on video:
ffmpeg -i temp.mp4 -i logo.png -filter_complex "overlay=10:main_h-overlay_h-10" logo.mp4

To Get thumbnail from video:
ffmpeg -i temp.mp4 -vf thumbnail,scale=300:200 -frames:v 1 out.png

Create image from video:
ffmpeg -i -an -ss 00:00:05 -r 1 -vframes 1 -y thumb.png

Convert video from mov to mp4:
ffmpeg -i -vcodec copy -acodec copy out_input.mp4

Convert video in any size: eg scale=180:120 etc..
ffmpeg -i temp.mp4 -vf scale=640:360 temp_out.mp4

Mute Audio from video: eg 5:11 means audio will be audible during 5to11secs.
ffmpeg -i temp.mp4 -af atrim=5:11 out.mp4

Convert video from flv to mp4:
ffmpeg -i johny.flv -qscale 0 -ar 22050 -vcodec libx264 out_johny.mp4

Create GIF Animated file from video:
ffmpeg -i johny.flv -an -ss 00:00:10 -r 1 -vframes 30 -y -f gif johny.gif

Replacing another audio in a video file:
ffmpeg -i dummy.mp3 -i johny.flv final_video.mp4

Create images for each frame:
ffmpeg -i dust.mp4 image%d.jpg

Creating video from lots of images: here image name will be image1.jpg,image2.jpg...etc
ffmpeg -f image2 -i image%d.jpg image_to_video.mp4

Create MP3 from video file:
ffmpeg -i johny.flv -ab 192k audio.mp3

Create clip from long video:
ffmpeg -ss 00:00:27 -t 00:00:10 -i johny.flv -async 1 -qscale 3.5 -vcodec flv poem_cut.mp4

ffmpeg -i temp.mp4 -vf drawtext="fontfile=HelveticaMedium.ttf: \ text='Aftab Muni...': fontcolor=red: fontsize=20: x=(w-text_w)/2: y=(h-text_h-line_h)/2:enable='between(t,5,10)'" -codec:a copy output.mp4

For more information and examples, please go to

Get all records nearby locations with latitude and longitude from database in particular kilometer radius

A query to get this is given below:

$latitude = '35.985';
$longitude = '-48.45';
$kilometer = '10';

$query = "SELECT *,( 3959 * acos( cos( radians(" . $latitude . ") ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(" . $longitude . ") ) + sin( radians(" . $latitude . ") ) * sin( radians( latitude ) ) ) ) AS distance FROM tbl_hotels HAVING distance < " . $kilometer . " ORDER BY distance";

NOTE: "latitude" & "longitude" are the column name of tbl_hotels

Above query will display hotels available in the radius of 10KM from given latitude and longitude.