In this post I will post a code example to generate a SharePoint embedCode for the uploaded videos , In SharePoint you can add three different types of video files 
  1. Upload video 
  2. Provide link to the video
  3. Using EmbedCode

if you use the third option the field VideoSetEmbedCode will contain the embed iframe of the video  but if you use the first option the Field VideoSetEmbedCode will remain empty , although you can get the embed code any time manually as you play the video.

The question is how to get the EmbedCode Programatically ? let us first check the format of the automatically generated embed code by SharePoint
it's simply Iframe with Src attribute with different set of parameters
  1. Player Url            "/_layouts/15/videoembedplayer.aspx"
  2. Some Parameter like:
    1. Site  : Site ID
    2. Web :Web ID
    3. Folder :Actually this is the current video Item ID not the parent Folder ID (Don't know why it's named as Folder)
    4. img: Thumbnail image of the Video
    5. lowner: if it equals 1 the owner name will be displayed 
    6. lTitle: if it equals  1 the title will be displayed
The question is how to construct this from the VideoItem  the code below do the trick

it first check if the VideoSetEmbedCode is not empty then if it's empty it constructs the EmbedCode in the same manner SharePoint does