How to convert url to embed code from youtube and vimeo url dynamically.

Some video projects includes google api need to embed Youtube video url dynamically. Here is the solution for extracting the unique id from url and convert them to embed form. Follow the step wise step:

Get youtube vedio thumbnail you can get thumbnail of any youtube vedio with the url Large thumbnail : http://img.youtube.com/vi/$vedio_id/0.jpgSmall thumbnail : http://img.youtube.com/vi/$vedio_id/1.jpg and so on…